esrap ships a ParenthesizedExpression handler ("Acorn produces it"), but the precedence machinery wraps the node AGAIN wherever grouping is needed, so the group prints twice:
// tree: CallExpression(callee: ParenthesizedExpression(SequenceExpression))
// i.e. acorn with preserveParens on `(0, f)("x");`
prints
and grows one layer per parse -> print roundtrip. Suggested fix: give ParenthesizedExpression a precedence rank (it IS a group - 20), or make the wrap checks see through it.
Context: found by a parse -> print -> reparse structural gate over a ~8.5k-file TS/JS corpus while adopting esrap in core-js's build plugin, then re-verified in isolation. esrap 2.3.5; the ASTs below come from @typescript-eslint/typescript-estree 8.67 with loc/range enabled, so the repros are independent of our own (oxc-based) pipeline.
esrap ships a
ParenthesizedExpressionhandler ("Acorn produces it"), but the precedence machinery wraps the node AGAIN wherever grouping is needed, so the group prints twice:prints
and grows one layer per parse -> print roundtrip. Suggested fix: give
ParenthesizedExpressiona precedence rank (it IS a group - 20), or make the wrap checks see through it.Context: found by a parse -> print -> reparse structural gate over a ~8.5k-file TS/JS corpus while adopting esrap in core-js's build plugin, then re-verified in isolation. esrap 2.3.5; the ASTs below come from
@typescript-eslint/typescript-estree8.67 withloc/rangeenabled, so the repros are independent of our own (oxc-based) pipeline.