codegen.c: `yield` outside of method is now `SyntaxError`.
MODIFY
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
@@ -2355,7 +2355,7 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_YIELD:
{
codegen_scope *s2 = s;
- int lv = 0, ainfo = 0;
+ int lv = 0, ainfo = -1;
int n = 0, sendv = 0;
while (!s2->mscope) {
@@ -2365,8 +2365,8 @@ codegen(codegen_scope *s, node *tree, int val)
}
if (s2) {
ainfo = s2->ainfo;
- if (ainfo < 0) codegen_error(s, "invalid yield (SyntaxError)");
}
+ if (ainfo < 0) codegen_error(s, "invalid yield (SyntaxError)");
push();
if (tree) {
n = gen_values(s, tree, VAL, 0);

MODIFY
test/t/syntax.rb
test/t/syntax.rb
@@ -35,9 +35,10 @@ assert('super', '11.3.4') do
end
assert('yield', '11.3.5') do
- assert_raise LocalJumpError do
- yield
- end
+# it's syntax error now
+# assert_raise LocalJumpError do
+# yield
+# end
assert_raise LocalJumpError do
o = Object.new
def o.foo

codegen.c: `yield` outside of method is now `SyntaxError`.