From 8fd474419bae2c806b76832fe0b56cbfda5f7e75 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Sun, 1 Oct 2023 13:37:16 +0200 Subject: [PATCH] Add missing class name binding (#3328) --- boa_engine/src/bytecompiler/class.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boa_engine/src/bytecompiler/class.rs b/boa_engine/src/bytecompiler/class.rs index 98db47e573..d49713d973 100644 --- a/boa_engine/src/bytecompiler/class.rs +++ b/boa_engine/src/bytecompiler/class.rs @@ -595,6 +595,9 @@ impl ByteCompiler<'_, '_> { self.emit_opcode(Opcode::Pop); if let Some(class_env) = class_env { + self.emit_opcode(Opcode::Dup); + self.emit_binding(BindingOpcode::InitConst, class_name.into()); + let env_index = self.pop_compile_environment(); self.patch_jump_with_target(class_env, env_index); self.emit_opcode(Opcode::PopEnvironment); @@ -603,10 +606,7 @@ impl ByteCompiler<'_, '_> { self.emit_opcode(Opcode::PopPrivateEnvironment); if !expression { - self.emit_binding( - BindingOpcode::InitVar, - class.name().expect("class statements must have a name"), - ); + self.emit_binding(BindingOpcode::InitVar, class_name.into()); } } }