Skip to content

Fix VariableDeclaration visitors#6288

Merged
sokra merged 1 commit intowebpack:nextfrom
ooflorent:fix_variable_hook
Jan 12, 2018
Merged

Fix VariableDeclaration visitors#6288
sokra merged 1 commit intowebpack:nextfrom
ooflorent:fix_variable_hook

Conversation

@ooflorent
Copy link
Copy Markdown
Contributor

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

Comment thread lib/Parser.js
for(const declarator of declarators) {
if(statement.type !== "VariableDeclaration")
return;
const hookMap = statement.kind === "const" ? this.hooks.varDeclarationConst :
Copy link
Copy Markdown
Contributor 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
Copy Markdown
Contributor

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

Copy link
Copy Markdown
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.

Comment thread lib/Parser.js Outdated

prewalkVariableDeclarators(declarators) {
for(const declarator of declarators) {
if(statement.type !== "VariableDeclaration")
Copy link
Copy Markdown
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
Copy Markdown
Contributor 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
Copy Markdown
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.

Comment thread lib/Parser.js Outdated
walkVariableDeclarators(declarators) {
for(const declarator of declarators) {
walkVariableDeclaration(statement) {
if(statement.type !== "VariableDeclaration")
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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