diff --git a/crates/oxc_codegen/tests/integration/comments.rs b/crates/oxc_codegen/tests/integration/comments.rs index d2f9b79549b36..e74f1df6f25d6 100644 --- a/crates/oxc_codegen/tests/integration/comments.rs +++ b/crates/oxc_codegen/tests/integration/comments.rs @@ -436,6 +436,12 @@ void /* @__PURE__ */ function() {}(); typeof /* @__PURE__ */ function() {}(); ! /* @__PURE__ */ function() {}(); delete /* @__PURE__ */ (() => {})();", + "const Foo = /* @__PURE__ */ (((() => {})()))", + "const Foo = /* @__PURE__ */ (() => { })() as unknown as { new (): any }", + "const Foo = /* @__PURE__ */ (() => {})() satisfies X", + "const Foo = /* @__PURE__ */ (() => {})()", + "const Foo = /* @__PURE__ */ (() => {})()!", + "const Foo = /* @__PURE__ */ (() => {})()! as X satisfies Y", ]; snapshot("pure_comments", &cases); diff --git a/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap b/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap index daee6a5408d2a..f58405213aa67 100644 --- a/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap +++ b/crates/oxc_codegen/tests/integration/snapshots/pure_comments.snap @@ -435,3 +435,35 @@ void /* @__PURE__ */ function() {}(); typeof /* @__PURE__ */ function() {}(); !/* @__PURE__ */ function() {}(); delete /* @__PURE__ */ (() => {})(); + +########## 25 +const Foo = /* @__PURE__ */ (((() => {})())) +---------- +const Foo = /* @__PURE__ */ (() => {})(); + +########## 26 +const Foo = /* @__PURE__ */ (() => { })() as unknown as { new (): any } +---------- +const Foo = (/* @__PURE__ */ (() => {})() as unknown) as { + new (): any +}; + +########## 27 +const Foo = /* @__PURE__ */ (() => {})() satisfies X +---------- +const Foo = ((/* @__PURE__ */ (() => {})()) satisfies X); + +########## 28 +const Foo = /* @__PURE__ */ (() => {})() +---------- +const Foo = /* @__PURE__ */ (() => {})(); + +########## 29 +const Foo = /* @__PURE__ */ (() => {})()! +---------- +const Foo = ((/* @__PURE__ */ (() => {})())!); + +########## 30 +const Foo = /* @__PURE__ */ (() => {})()! as X satisfies Y +---------- +const Foo = ((((/* @__PURE__ */ (() => {})())!) as X) satisfies Y); diff --git a/crates/oxc_parser/src/js/expression.rs b/crates/oxc_parser/src/js/expression.rs index 1b691b6801844..612173dd52c56 100644 --- a/crates/oxc_parser/src/js/expression.rs +++ b/crates/oxc_parser/src/js/expression.rs @@ -1247,7 +1247,7 @@ impl<'a> ParserImpl<'a> { } fn set_pure_on_call_or_new_expr(expr: &mut Expression<'a>) { - match &mut expr.without_parentheses_mut() { + match &mut expr.get_inner_expression_mut() { Expression::CallExpression(call_expr) => { call_expr.pure = true; }