fix(scripts): remove unreachable branch in validate-modules.js#406
Closed
shaun0927 wants to merge 1 commit intoEvoMap:mainfrom
Closed
fix(scripts): remove unreachable branch in validate-modules.js#406shaun0927 wants to merge 1 commit intoEvoMap:mainfrom
shaun0927 wants to merge 1 commit intoEvoMap:mainfrom
Conversation
The inner 'typeof exported[k] !== function' check sits inside 'typeof exported[k] === function', so it can never be true. The intended 'declared but not callable' error is unreachable, and the validator silently accepts everything it claims to check. Without a manifest of expected function keys the script cannot decide which members should be functions, so the nested block is removed rather than given a fake fix. The outer typeof check was already a no-op in every call site the script is invoked with, so behaviour is unchanged; the code now matches that behaviour honestly.
Collaborator
|
Thank you, @shaun0927. We looked at this one closely and decided not to port it: the removed block is a no-op after the inner predicate normalization, so deleting it would not change behavior, and we prefer keeping the defensive shape in case we later thread a declaration manifest through |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
scripts/validate-modules.js:27-28:The inner
typeof !== 'function'can never be true under the outertypeof === 'function', so the "declared but not callable" error isunreachable and the validator silently accepts everything it claims to
check. The script is in the package because of a comment on line 3
("exported functions are callable (typeof check)") that the code does
not actually enforce.
Fix
Without a manifest of expected function keys the script cannot decide
which exported members ought to be functions, so the nested block is
removed rather than given a fake fix. Behaviour is unchanged — in
practice the original block never produced any output — but the code
now matches that behaviour honestly and stops giving false assurance
to readers.
Testing
Output is identical before and after this change for every module the
script is invoked with.
Scope
One file, -11/+6.