Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 487b86543794b9effc862db130ea37a2e0e36ca7..0f24995c92a9b150b38f002a73ea5d70ff61a360 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -45,6 +45,13 @@ Handle<BytecodeArray> BytecodeGenerator::MakeBytecode(CompilationInfo* info) { |
// Visit statements in the function body. |
VisitStatements(info->literal()->body()); |
+ // If the last bytecode wasn't a return, then return 'undefined' to avoid |
+ // falling off the end. |
+ if (!builder_.HasExplicitReturn()) { |
+ builder_.LoadUndefined(); |
+ builder_.Return(); |
+ } |
+ |
set_scope(nullptr); |
set_info(nullptr); |
return builder_.ToBytecodeArray(); |