Skip to content

ParenthesizedExpression is wrapped again by the precedence logic - parens accrete on every reprint #176

Description

@zloirock

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

((0, f))("x");

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions