From 9c2a1b61b97e73b4396f92ae1fa8e7a4191c05ad Mon Sep 17 00:00:00 2001 From: overlookmotel <557937+overlookmotel@users.noreply.github.com> Date: Tue, 10 Dec 2024 02:28:25 +0000 Subject: [PATCH] refactor(transformer): `duplicate_expression` do not produce temp var 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). --- crates/oxc_transformer/src/common/duplicate.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/oxc_transformer/src/common/duplicate.rs b/crates/oxc_transformer/src/common/duplicate.rs index c44a95bf3f192..5728f03441d99 100644 --- a/crates/oxc_transformer/src/common/duplicate.rs +++ b/crates/oxc_transformer/src/common/duplicate.rs @@ -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), };