Browse Source

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

Luke Wilde 2 years ago
parent
commit
b914680f0c
1 changed files with 2 additions and 0 deletions
  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 });