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

Description

@oskardahlberg

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,

if (node.operator === "**" && left.type === "UnaryExpression" && left.extra && !left.extra.parenthesizedArgument) {

My best guess is that it should also check if "left.extra.paranthesized" is false!

Cheers

Activity

jmm

jmm commented on Apr 30, 2016

@jmm
Member

Thanks @oskardahlberg. I noticed that too and it seems like a bug to me.

kaicataldo

kaicataldo commented on Sep 5, 2016

@kaicataldo
Member
danez

danez commented on Sep 5, 2016

@danez
Member

Yes this was Fixed in 6.9.0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jmm@danez@hzoo@oskardahlberg@kaicataldo

        Issue actions

          Wrapping a UnaryExpression and an exponential base in parentheses gives error · Issue #26 · babel/babylon