-
Notifications
You must be signed in to change notification settings - Fork 871
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
let, const as VariableDeclaration? #113
Comments
LexicalDeclaration is not supported by escodegen, esprima also generates VariableDeclaration for let and const AFAIK. I'd postpone fixing it before escodegen supports it, or do it in sync, otherwise produced AST will break code generation. |
If it's doing this for ES6 parsing, then it's wrong. |
@rwaldron side question: what "syntactics" are different? I totally understand the different runtime semantics. But moreover, I think it's a valid point that tools which cooperate in an ecosystem have to coordinate evolution. One could argue that a code generator needs to evolve with or before a code parser, because if the other way around, the code generator breaks on unrecognized tree syntax. |
The entire basis of this conversation is ill-founded. If a parser API node's |
// This shouldn't be allowed, but it is
let a = 1;
let a = 2; // This shouldn't be allowed, but it is
{
var a = 1;
let a = 2;
}
// This shouldn't be allowed, but it is
function f(x) {
let x = 1;
} |
Reporting a parsing bug to a parser is not ill-founded.
I see, I thought this practice was to be intentionally aligned with the spec, my mistake.
Except when they're not.
Yes, I saw that and still filed the bug because it's insufficient.
Again, parser bug reported to a parser.
Am I to assume that what you actually mean is that Reflect.parse needs to be updated? Surely you didn't actually expect me to report this same bug on a ticket filed for some unrelated syntax. |
@rwaldron I think his point is that the SpiderMonkey parser API defines the "one true standard" for tree syntax, and all other (conforming) tools simply rely on that syntax. So, if there's a desire to change the syntax of the tree, such as it being insufficient for certain syntax/grammar, then the spidermonkey parser API is what needs to change first. |
@getify thanks, that's much clearer. |
@rwaldon Since the parser API as described on the Mozilla wiki does not cover ES6, but rather Mozilla's own JS 1.8, there is no standard to follow. If someone would actually fix this, and update the API document, I would happily make Acorn conform to that. For now, I consider Esprima the normative tool, and Acorn is following that. If you can convince them to change their format, ping us, and we'll follow. |
@marijnh these are understandable constraints, thanks for the additional clarification. |
@marijnh I think we can close this issue now. |
Currently let and const nodes have
type: "VariableDeclaration"
, but these syntactic forms aren't defined as VariableDeclaration in the specification. The correct grammar definition isLexicalDeclaration, defined here: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-let-and-const-declarations
The text was updated successfully, but these errors were encountered: