Skip to content

Codegen: Missing parentheses for TaggedTemplateExpression inside NewExpression #22961

Description

@guyutongxue

For following input:

Playground Link

const foo = () => (args) => class A {};
new (foo()`bar`)();

The printed code mistakenly drops parentheses around foo()`bar`:

// (Printed)
const foo = () => (args) => class A {};
new foo()`bar`();

...which will change the semantic since () after foo immediately ends NewExpression.


This bug was first observed from SvelteJS' compiler and we'd discovered same issue for a bunch of transpiler including Babel, oxc, SWC, and more.

Metadata

Metadata

Assignees

Labels

A-codegenArea - Code Generation

Type

Fields

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions