You likely wrote something like this:
Whether it should be evaluated as (-a) ** b
or -(a ** b)
is ambiguous. In mathematics, -x2 means -(x ** 2)
— and that's how many languages, including Python, Haskell, and PHP, handle it. But making the unary minus operator take precedence over **
breaks symmetry with a ** -b
, which is unambiguously a ** (-b)
. Therefore, the language forbids this syntax and requires you to parenthesize either side to resolve the ambiguity.
Other unary operators cannot be the left-hand side of exponentiation either.
await a ** b
!a ** b
+a ** b
~a ** b