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
"var let" should be allowed in non-strict mode [$15] #149
Comments
I believe this happens because https://github.com/eslint/espree/blob/master/espree.js#L3596 I think this might be as simple as removing "let" from this statement: https://github.com/eslint/espree/blob/master/lib/syntax.js#L154 @btmills @xjamundx @FredKSchott do any of you have time to look at fixing this? |
Early next week if no one claims it first. |
Assuming |
@xjamundx no, |
Actually, there are some implications to that original suggestion that make this a little more involved:
I'll do some more work on this, but given that I'm largely unfamiliar with the code, I might end up handing this back off to you 😄
|
OK, so probably makes sense to keep |
And by "early next week"....I'll try again in the coming week. |
👍 |
The thing is that something like |
I wonder if Acorn handles this correctly. Might be useful to see what they're doing. |
Cool. Will check on how they're doing it! |
With the latest version of acorn
|
I sort of gave up this when thinking harder about the complexity. May take another stab if I get motivated today though after looking at some of the other espree isues... |
Going to throw up a PR with broken tests, just to keep me motivated.... |
Acorn issue: acornjs/acorn#359 |
As a heads up, this was fixed in esprima. |
I just got bit by this with (let[a] = b); This should be valid, but is giving me the error "Parsing error: Unexpected token let". |
Yup, it's an upstream issue with Acorn. |
IIUC, this issue can be closed now. |
I confirmed it. "use strict";
const espree = require("espree");
const ast = espree.parse(
`var let = 0`,
{
ecmaVersion: 6,
sourceType: "script"
}
);
console.log(JSON.stringify(ast, null, 4)); {
"type": "Program",
"start": 0,
"end": 11,
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 11,
"declarations": [
{
"type": "VariableDeclarator",
"start": 4,
"end": 11,
"id": {
"type": "Identifier",
"start": 4,
"end": 7,
"name": "let"
},
"init": {
"type": "Literal",
"start": 10,
"end": 11,
"value": 0,
"raw": "0"
}
}
],
"kind": "var"
}
],
"sourceType": "script"
} |
@mysticatea how about the program I mentioned? |
@michaelficarra It works http://astexplorer.net/#/5L9D8euj22. Been fixed in acornjs/acorn@8f46eb5 couple of months ago. |
I'll add a test case just to be sure. |
I guess money goes to @marijnh in such case 😄 |
Yup. @marijnh, once this is closed, you can claim the bounty on this issue. |
Fix: Ensure 'var let' works (fixes #149)
Repro:
See jquery/esprima#1048
There is a $15 open bounty on this issue. Add to the bounty at Bountysource.
The text was updated successfully, but these errors were encountered: