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
Is MemberExpression a Pattern? #162
Comments
Sounds like duplicate of #161 |
@RReverser: you are basically correct; I had not seen that issue. Apologies for opening a near-duplicate. I do think it would be helpful if the description of (One criteria for a good enough description of |
I agree, it's just that neither of proposed PRs currently fixes it correctly - in both cases, you end up with either breaking correct representation or duplicating same lists of actual node types in every field. While ESTree spec itself is really more of representation spec rather than precise type system (this is best left to ESTree's TypeScript definitions which describe relations between different types more correctly), this is something we could fix in this specific case by creating a descendant of |
es5.md says:
But this is not true;
MemberExpression
is defined thusly:This is great, because
ForInStatement
is defined thusly:…and indeed we can use a MemberExpression in a ForInStatement, and it works exactly as you would expect:
However,
es5.md
also declaresFunction.params
as[Pattern]
andCatchClause.param
asPattern
, and ECMA262 5.1 clearly restricts these to[Identifier]
andIdentifier
respectively, so perhaps it is the definitions ofMemberExpression
andForInStatement
which are wrong?(Actually,
ForInStatement
is definitely wrong; per @michaelficarra's reasoning in #160,ForInStatement.Left
can actually be anyExpression
(see https://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4, where it is a LeftHandSideExpression which in turn can be any expression), which means that the following bizarre construction is (syntactically) legal:…and for consistency should be representable as an estree.)
I am not sure which of these solutions is preferable, either in general or specifically in terms of impact on the the estree es201[567].md specs; unfortunately I have not managed to get my head around the full ECMA262 7.0 spec sufficiently to understand what precisely is now allowed in function and catch clause parameter declarations.
The text was updated successfully, but these errors were encountered: