This repository was archived by the owner on May 19, 2018. It is now read-only.
This repository was archived by the owner on May 19, 2018. It is now read-only.
Wrapping a UnaryExpression and an exponential base in parentheses gives error #26
Closed
Description
Both expressions below produces the same error(using the babel online repl in various settings),
"Illegal expression. Wrap left hand side or entire exponentiation in parentheses."
(-2) ** 2;
((-2) ** 2);
According to this reference it should work,
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Exponentiation
Looking briefly at the source,
babylon/src/parser/expression.js
Line 186 in 8b15081
My best guess is that it should also check if "left.extra.paranthesized" is false!
Cheers
Activity
jmm commentedon Apr 30, 2016
Thanks @oskardahlberg. I noticed that too and it seems like a bug to me.
kaicataldo commentedon Sep 5, 2016
Looks like this has actually been fixed 🎉 https://github.com/babel/babylon/blob/master/src/parser/expression.js#L191-L199
danez commentedon Sep 5, 2016
Yes this was Fixed in 6.9.0