Closed
Description
reproduction: https://stackblitz.com/edit/stackblitz-starters-9gkcmv?file=index.js&view=editor
const { parse, print, types } = require('recast');
const b = types.builders;
const { code } = print(
b.binaryExpression(
'**',
b.unaryExpression('-', b.numericLiteral(1)),
b.numericLiteral(2)
)
);
console.log(code);
console.log(eval(code));
it prints -1 ** 2
which is invalid syntax:
Uncaught SyntaxError: Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence
expected: (-1) ** 2
related but not fixed by #363
Metadata
Metadata
Assignees
Labels
No labels