-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: scope redeclared variable #4854
Conversation
LGTM One thing we might want to consider while moving forward with block scoping is that we don't need to use IIFEs. The changes in this PR could just be wrapped in curly braces and create a new block scope. |
@silverwind It is already supported in strict mode. |
Oh, I never knew, thanks! |
@silverwind I think it's just part of the definition of block scope. It works at least back to io.js v1.0.0. |
So called standalone blocks seem to have been around since JavaScript 1.0 according to MDN. It's the combination of strict mode creating a scope on them and block scoped vars that makes them useful now. |
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it.
7cb700f
to
73bb5bb
Compare
I sure like the idea of not having the creation of a function as unnecessary overhead. Converted to block scope, force pushed, looks good. |
LGTM |
1 similar comment
LGTM |
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: nodejs#4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
Landed in 34daaa7 |
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: #4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: nodejs#4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
Added the lts-watch-v4.x label. For commits like this, getting them on the lts-watch list for v4.x helps significantly when determining which commits need to be cherry picked. We cherry pick almost all the test commits unless they specifically relate to semver-minor/major updates. |
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: #4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: #4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: #4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: #4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
`test-assert.js` redeclares a variable with `var`. This change converts it to a `const` declaration and wraps it in a standalone block to scope it to just the test that uses it. PR-URL: nodejs#4854 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: targos - Michaël Zasso <[email protected]>
test-assert.js
redeclares a variable withvar
. This change convertsit to a
const
declaration and wraps it in an IIFE to scope it to justthe test that uses it.