Sfoglia il codice sorgente

LibJS: Fix bogus bytecode codegen for "catch" parameters

Add a missing '!' so that catch clauses with a named parameter actually
generate a SetVariable opcode.
Andreas Kling 3 anni fa
parent
commit
6fc3c14b7a
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  1. 1 1
      Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

+ 1 - 1
Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

@@ -1200,7 +1200,7 @@ void TryStatement::generate_bytecode(Bytecode::Generator& generator) const
             generator.emit<Bytecode::Op::LeaveUnwindContext>();
         m_handler->parameter().visit(
             [&](FlyString const& parameter) {
-                if (parameter.is_empty()) {
+                if (!parameter.is_empty()) {
                     // FIXME: We need a separate DeclarativeEnvironment here
                     generator.emit<Bytecode::Op::SetVariable>(generator.intern_identifier(parameter));
                 }