-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Disallow let\const declarations in the same scope with var declarations. #2027
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
Conversation
…at var is not shadowed by the let\const from the inner scope
// Do not consider let and const declarations, as duplicate block-scoped declarations | ||
// are handled by the binder. | ||
// We are only looking for var declarations that step on const declarations from a | ||
// are handled by the binder. |
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.
Trim this trailing whitespace.
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.
done
👍 |
// let x; | ||
// var x; | ||
// } | ||
// 'var x' will be placed into the function locals and 'let x' - into the locals of the block |
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.
So you are saying that you want vars and lets to go to one place, because you want them to collide. The choice of function locals as opposed to block locals is arbitrary, it just has to be the same for both declaration kinds. Correct?
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.
Yeah, i'd add a comment to that effect. I think using hte function as the location makes sense though, as that's where we put parameters. (we should also add tests for parameters/locals/lets (if they collide or not))
👍 |
Disallow let\const declarations in the same scope with var declarations.
Prevent nested let\const to shadow hoisted variables Fixes #1910.