JS: correctly treat ES2015 modules as being in strict-mode in the JavaScript extractor#4092
Merged
codeql-ci merged 3 commits intogithub:mainfrom Aug 19, 2020
Merged
Conversation
esbena
reviewed
Aug 18, 2020
Contributor
esbena
left a comment
There was a problem hiding this comment.
LGTM. Modulo the missing extractor version bump.
| return 3; | ||
| } | ||
| } | ||
| return foo(); // `foo` is not defined, because we are in strict-mode. |
Contributor
There was a problem hiding this comment.
sanity check: this is the only test that changes output due to the extractor fixup, right? The two other tests remain unchanged.
esbena
previously approved these changes
Aug 18, 2020
Contributor
esbena
left a comment
There was a problem hiding this comment.
Lets land this first, and rebase the other extractor PR on top of that.
Contributor
Author
|
@esbena can I get a final approve? |
esbena
approved these changes
Aug 19, 2020
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.
I was trying to understand the QL/Java code for module detection, and I encountered this bug.
The extractor would always overwrite
isStrictwith the result fromhasUseStrict(nd.getBody()).So whether the file was a ES2015 module would be ignored while extracting.
The
prevIsStrictvariable should not be necessary (becauseProgramis the top-most node visited), but I added it anyway because I feel it is good style.The only impact this has in the extractor is function/block scopes for functions, so I added a test for that.