Skip to content
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

Bug in exponential operator #384

Closed
nzakas opened this issue Feb 10, 2016 · 9 comments
Closed

Bug in exponential operator #384

nzakas opened this issue Feb 10, 2016 · 9 comments

Comments

@nzakas
Copy link
Contributor

nzakas commented Feb 10, 2016

When using Acorn 3.0.2 and ecmaVersion 7, the following code throws an error but should not:

a++ ** 2;

The grammar specifically allows both ++ and -- in the base position:

The grammar is as follows (per this comment):

ExponentiationExpression :
  UnaryExpression
  UpdateExpression `**` ExponentiationExpression

UpdateExpression :
  LeftHandSideExpression `++`
  LeftHandSideExpression `--`
  `++` UnaryExpression
  `--` UnaryExpression

UnaryExpression :
  UpdateExpression
  `delete` UnaryExpression
  `void` UnaryExpression
  `typeof` UnaryExpression
  `+` UnaryExpression
  `-` UnaryExpression
  `~` UnaryExpression
  `!` UnaryExpression
@nzakas
Copy link
Contributor Author

nzakas commented Feb 11, 2016

I'm going to take a look at this, will see how far I get.

@nzakas
Copy link
Contributor Author

nzakas commented Feb 11, 2016

Gave this a shot and couldn't get very far. It seems like sawUnary needs to end up false whenever there's ++ or --, but when I do that, then I get an error "Assigning to rvalue". I can't seem to track down where that's coming from.

@ljharb
Copy link
Contributor

ljharb commented Feb 11, 2016

Does (a++) ** 2 have the same error, or does that parse?

@nzakas
Copy link
Contributor Author

nzakas commented Feb 11, 2016

That parses just fine because of the parens (same escape hatch for all other unary operators).

@marijnh
Copy link
Member

marijnh commented Feb 17, 2016

I think attached patch should take care of this. Take a look.

@nzakas
Copy link
Contributor Author

nzakas commented Feb 17, 2016

Thanks!

@ljharb
Copy link
Contributor

ljharb commented Feb 21, 2016

@marijnh Thanks, when is a release planned that includes this fix?

@marijnh
Copy link
Member

marijnh commented Feb 25, 2016

I just published 3.0.4.

@ljharb
Copy link
Contributor

ljharb commented Feb 25, 2016

👍 thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants