Skip to content
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

[[FIX]] es6: export on var, let, const exports all variables, not just the first one #2252

Closed
wants to merge 4 commits into from

Conversation

lukeapage
Copy link
Member

Fixes #2248

Looks like code will have to be expanded again to work with export and de-structuring in the same var/let/const but I think its alot more work. This looks to me like a move in the right direction and fixes the bug and add tests.

I've signed the CLA.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 96.33% when pulling 0305541 on lukeapage:fix-2248 into 231557a on jshint:master.

@caitp
Copy link
Member

caitp commented Mar 12, 2015

oh man, I thought this was filed on traceur for some reason. Mark this as fixing the issue I just opened then, hah =)

@@ -863,7 +863,7 @@ var JSHINT = (function() {
funct["(blockscope)"].stack();
advance("let");
advance("(");
state.syntax["let"].fud.call(state.syntax["let"].fud, false);
state.syntax["let"].fud.call(state.syntax["let"].fud);
Copy link
Member

Choose a reason for hiding this comment

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

@rwaldron do you have any idea why we're calling it this way instead of state.tokens.curr.fud(false);? or not "curr" in this case but "prev"

Copy link
Member Author

Choose a reason for hiding this comment

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

seems like it was a common pattern - found lots of commits using it - 5924b2a#diff-180beb5359ee54413144b3d8200d7504R3975

one thing is I didn't even notice it because its hard to compare & notice that state.syntax["let"].fud is repeated identically.

removing it doesn't have any effect, further notice that commit has a mix of different styles. I can't find a single committer introducing one style or the other.

Most of the other non-let/var/const don't use call. My vote would be to remove the call. I have an extra commit waiting, just say the word.

Copy link
Member

Choose a reason for hiding this comment

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

The problem is if any of these constructs ever mutate their this binding, then you end up with problems if calling them that way, so I would prefer we didn't do that

Copy link
Member

Choose a reason for hiding this comment

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

that, and it's just harder to read the .call() invocations =)

Copy link
Member Author

Choose a reason for hiding this comment

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

you want me to push the change onto this PR?

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer it yeah

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 96.33% when pulling e71a798 on lukeapage:fix-2248 into 231557a on jshint:master.

if (inexport) {
exported[state.tokens.next.value] = true;
state.tokens.next.exported = true;
}
Copy link
Member

Choose a reason for hiding this comment

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

setting the exported flag should happen after the call to identifier()(on the next line, which will make sure that it's actually an identifier)

@caitp
Copy link
Member

caitp commented Mar 12, 2015

other than those comments it looks good to me

@lukeapage
Copy link
Member Author

Thanks, I understand now - was my first time looking at the code, so I didn't realise you could get curr and prev and that was the same as lookup on statements.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 96.33% when pulling df84b6a on lukeapage:fix-2248 into 231557a on jshint:master.

"export class MyClass { }",
"export var varone = 1, vartwo = 2;",
"export const constone = 1, consttwo = 2;",
"export let letone = 1, lettwo = 2;"
Copy link
Member

Choose a reason for hiding this comment

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

👍

@caitp
Copy link
Member

caitp commented Mar 13, 2015

lgtm, thanks

@caitp caitp closed this in 3ce1267 Mar 13, 2015
jugglinmike pushed a commit to jugglinmike/jshint that referenced this pull request Mar 15, 2015
@lukeapage lukeapage deleted the fix-2248 branch April 25, 2015 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

defined but never used on exported vars
4 participants