-
Notifications
You must be signed in to change notification settings - Fork 29.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: eval a strict function #5250
Conversation
Test fails for me in 3.x and passes in 4.0.0 and up, which is consistent with it detecting the bug it is designed to test, so that's good. (EDIT: Have to comment out |
@Trott may be because template strings were not available before 4.x? |
@thefourtheye Yeah, and maybe other stuff too. I think there's at least one arrow functions in there now, for example. |
@Trott @thefourtheye should I rewrite this without template strings to make tests running this on old versions possible? |
@kthelgason Ya, since we claim that this |
f7ea0f9
to
cd5b3fc
Compare
@thefourtheye agreed. Fixed and pushed. |
@@ -0,0 +1,28 @@ | |||
/* eslint-disable strict */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in strict mode running this will fail as bar
is undefined until the code has been eval
ed. If this line is not present the build will fail linting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to disable the no-undef rule inline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I could have been clearer above, the issue here is that this code is not valid in strict mode, since eval
in strict mode does not introduce new variables into the surrounding scope. Therefore this file cannot have strict mode enabled, and hence this linter rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, my bad.
This test ran perfectly fine in 3.x (with The problem (which should not be "fixed") was in If you want to restore the template string for better code hygiene, feel free. |
@Trott Ok, I still feel that there might be some value to being able to run the test under 0.10 to see the failure. |
@kthelgason Fair enough. I'm not opposed to the current format or anything. |
@Trott willing to land this or looking for more eyes on it first? |
LGTM |
LGTM. CI Run: https://ci.nodejs.org/job/node-test-pull-request/1912/ |
PR-URL: #5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Landed in 25eedf0 |
PR-URL: #5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #5250 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This PR adds a regression test for the bug mentioned in #2245 where when a strict function is
eval
ed it would not capture it's context.