Skip to content

Fix VariableDeclaration visitors #6288

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

Merged
merged 1 commit into from
Jan 12, 2018
Merged

Conversation

ooflorent
Copy link
Member

What kind of change does this PR introduce?

bugfix

Did you add tests for your changes?

no

If relevant, link to documentation update:

n/a

Summary

Prior this change, the VariableDeclaration nodes were not properly walked. The kind property was read on the VariableDeclarator instead of the parent node.

Sorry for the diff but git decided to go this way.

Does this PR introduce a breaking change?

no

lib/Parser.js Outdated
for(const declarator of declarators) {
if(statement.type !== "VariableDeclaration")
return;
const hookMap = statement.kind === "const" ? this.hooks.varDeclarationConst :
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the main change

@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

Copy link
Member

@TheLarkInn TheLarkInn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me. For most parser stuff, I feel good letting @sokra take a review as well. 👍 Nice work.

lib/Parser.js Outdated

prewalkVariableDeclarators(declarators) {
for(const declarator of declarators) {
if(statement.type !== "VariableDeclaration")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed, shouldn't the function only be called for VariableDeclarations?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, technically yes but this is not how the parser uses it. walkVariableDeclaration is also called with ForStatement#init or For*Statement#left which also accepts identifiers or destructured patterns.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm... could you move the "if" to these calls.

lib/Parser.js Outdated
walkVariableDeclarators(declarators) {
for(const declarator of declarators) {
walkVariableDeclaration(statement) {
if(statement.type !== "VariableDeclaration")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed, shouldn't the function only be called for VariableDeclarations?

@webpack-bot
Copy link
Contributor

@ooflorent Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@sokra sokra merged commit 4162471 into webpack:next Jan 12, 2018
@sokra
Copy link
Member

sokra commented Jan 12, 2018

Thanks

@ooflorent ooflorent deleted the fix_variable_hook branch January 22, 2018 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants