Explorar o código

LibJS/Bytecode: Make `yield` by itself yield undefined

Luke Wilde %!s(int64=2) %!d(string=hai) anos
pai
achega
b914680f0c
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

+ 2 - 0
Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

@@ -1600,6 +1600,8 @@ Bytecode::CodeGenerationErrorOr<void> YieldExpression::generate_bytecode(Bytecod
 
     if (m_argument)
         TRY(m_argument->generate_bytecode(generator));
+    else
+        generator.emit<Bytecode::Op::LoadImmediate>(js_undefined());
 
     auto& continuation_block = generator.make_block();
     generator.emit<Bytecode::Op::Yield>(Bytecode::Label { continuation_block });