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

Problem with the supplemental syntax in section 12.3 #1315

Closed
kwesibrunee opened this Issue Sep 27, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@kwesibrunee

kwesibrunee commented Sep 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 matches new a()() if the mandatory Arguments is removed, it matches both new a() and new a()() appropriately

@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

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.)

Collaborator

jmdyck commented Sep 27, 2018

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.)

@kwesibrunee

This comment has been minimized.

Show comment
Hide comment
@kwesibrunee

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,
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]

@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

jmdyck Sep 28, 2018

Collaborator

There is nothing that I see in the spec that precludes CallMemberExpression from matching new 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.

Collaborator

jmdyck commented Sep 28, 2018

There is nothing that I see in the spec that precludes CallMemberExpression from matching new 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.

@kwesibrunee

This comment has been minimized.

Show comment
Hide comment
@kwesibrunee

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]:
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment