Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upProblem with the supplemental syntax in section 12.3 #1315
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Sep 27, 2018
Collaborator
new a() is a NewExpression, specifically a MemberExpression. There's no reason that CallMemberExpression should match it. And if you change the grammar so that CallMemberExpression does match it, then you've just made the grammar ambiguous. (LeftHandSideExpression would match any MemberExpression in two different ways.)
|
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kwesibrunee
Sep 28, 2018
per the ES2019 grammar,
new MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] is part of Member Expression, which in turn is part of NewExpression. There is nothing that I see in the spec that precludes CallMemberExpression from matching new a() CallMemberExpression directly calls MemberExpression as its first non-terminal. If CallMemberExpression should not match MemberExpression, I don't see any reference to it in the spec. The Arguments non-terminal in CallMemberExpression is what I am questioning, since Arguments already exists in the new MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await] alternative
for reference:
MemberExpression[Yield, Await]:
PrimaryExpression[?Yield, ?Await]
MemberExpression[?Yield, ?Await] [Expression[+In, ?Yield, ?Await]]
MemberExpression[?Yield, ?Await] . IdentifierName
MemberExpression[?Yield, ?Await] TemplateLiteral[?Yield, ?Await, +Tagged]
SuperProperty[?Yield, ?Await]
MetaProperty
new MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
NewExpression[Yield, Await]:
MemberExpression[?Yield, ?Await]
new NewExpression[?Yield, ?Await]
kwesibrunee
commented
Sep 28, 2018
•
|
per the ES2019 grammar, for reference: MemberExpression[Yield, Await]: NewExpression[Yield, Await]: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Sep 28, 2018
Collaborator
There is nothing that I see in the spec that precludes
CallMemberExpressionfrom matchingnew a().
(You said yourself in the original post that CallMemberExpression does not match new a(), so I'm not clear on what you're saying.)
Anyhow, the grammar precludes it. Ignoring grammatical parameters (which are not pertinent to this discussion), we have
CallMemberExpression: MemberExpression Arguments
If you try to make CallMemberExpression match new a(), it's clear that () would match Arguments, so then you would have to make new a match MemberExpression, but this can't be done.
(You said yourself in the original post that Anyhow, the grammar precludes it. Ignoring grammatical parameters (which are not pertinent to this discussion), we have
If you try to make |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kwesibrunee
Sep 28, 2018
I found my issue, sorry for the confusion, I had accidentally shortened the following production
NewExpression[Yield, Await]:
MemberExpression[?Yield, ?Await]
new NewExpression[?Yield, ?Await]
to
NewExpression[Yield, Await]:
new opt MemberExpression[?Yield, ?Await]
which caused the strange behavior, thanks for helping me find my issue, you were very helpful.
kwesibrunee
commented
Sep 28, 2018
|
I found my issue, sorry for the confusion, I had accidentally shortened the following production NewExpression[Yield, Await]: to NewExpression[Yield, Await]: which caused the strange behavior, thanks for helping me find my issue, you were very helpful. |
kwesibrunee commentedSep 27, 2018
The supplemental Syntax listed in 12.3 for CallMemberExpression is actually the same as CoverCallExpressionAndAsyncArrowHead. What is the purpose of a supplemental syntax if it is the same as the original syntax.
CallMemberExpression[Yield, Await]:
MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
CoverCallExpressionAndAsyncArrowHead[Yield, Await]:
MemberExpression[?Yield, ?Await] Arguments[?Yield, ?Await]
I believe that CallMemberExpression should actually be:
CallMemberExpression[Yield, Await]:
MemberExpression[?Yield, ?Await]
with the mandatory Arguments there it does not match
new a()and only matchesnew a()()if the mandatory Arguments is removed, it matches bothnew a()andnew a()()appropriately