-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Use first binding for multiple var declarations #5745
Conversation
Since var declarations after initial binding have no effect, use the first declaration. Fixes babel#2378
@peey, thanks for your PR! By analyzing the history of the files in this pull request, we identified @existentialism and @loganfsmyth to be potential reviewers. |
Codecov Report
@@ Coverage Diff @@
## 7.0 #5745 +/- ##
=========================================
- Coverage 84.63% 84.6% -0.04%
=========================================
Files 282 282
Lines 9861 9864 +3
Branches 2766 2767 +1
=========================================
- Hits 8346 8345 -1
- Misses 997 1001 +4
Partials 518 518
Continue to review full report at Codecov.
|
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.
Nit: Is this still necessary?
https://github.com/babel/babel/pull/5745/files#diff-739bf54b7930434d653e3e1bbb701154R37?
@jridgewell I forgot. I'll have to check. Also, this shouldn't be merged yet, I just noticed an error in one of the tests: this should also have been renamed to I'll patch it up and update here |
@jridgewell I don't think we need it, so I have removed it. The reason being that there are only two categories of redeclarations - one we're fine with and one that result in an error. The redeclarations which result in an error are taken care of here And rest of them (like |
4a0483e
to
62755d0
Compare
Since var declarations after initial binding have no effect, use the first declaration (instead of last, as we were currently doing). This prevents a
param
binding from turning into avar
binding when a var declaration of the same identifier is made in the function body. Hence it fixes #2378