Skip to content

Commit

Permalink
refactor(transformer): duplicate_expression do not produce temp var…
Browse files Browse the repository at this point in the history
… for `super` (#7757)

`TransformCtx::duplicate_expression` method introduced in #7754 don't create a temp var for `super`. This prepares it for use in logical assignment operator transform (#7745).
  • Loading branch information
overlookmotel committed Dec 10, 2024
1 parent a750ebc commit 9c2a1b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/oxc_transformer/src/common/duplicate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,16 @@ impl<'a> TransformCtx<'a> {

self.var_declarations.create_uid_var(&ident.name, ctx)
}
// Reading `this` or `super` cannot have side effects, so no need for temp var
Expression::ThisExpression(this) => {
// Reading `this` cannot have side effects, so no need for temp var
let references = create_array(|| ctx.ast.expression_this(this.span));
return (expr, references);
}
Expression::Super(super_expr) => {
let references = create_array(|| ctx.ast.expression_super(super_expr.span));
return (expr, references);
}
// Anything else requires temp var
_ => self.var_declarations.create_uid_var_based_on_node(&expr, ctx),
};

Expand Down

0 comments on commit 9c2a1b6

Please sign in to comment.