summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y3
-rw-r--r--test/ruby/test_syntax.rb16
2 files changed, 17 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 7ca1197b37..b20141680e 100644
--- a/parse.y
+++ b/parse.y
@@ -13847,8 +13847,7 @@ value_expr_check(struct parser_params *p, NODE *node)
return NULL;
}
if (!(vn = value_expr_check(p, RNODE_RESBODY(r)->nd_body))) {
- void_node = 0;
- break;
+ return NULL;
}
if (!void_node) void_node = vn;
}
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 5065a1db33..79e373ea66 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -2013,6 +2013,8 @@ eom
assert_equal(1, b.new.foo(1), bug21256)
end
+ BUG_21669 = '[Bug #21669]'
+
def test_value_expr_in_condition
mesg = /void value expression/
assert_syntax_error("tap {a = (true ? next : break)}", mesg)
@@ -2026,6 +2028,20 @@ eom
assert_syntax_error("class << (return); end", mesg)
end
+ def test_value_expr_in_rescue
+ assert_valid_syntax("#{<<~"{#"}\n#{<<~'};'}", "#{BUG_21669} 1.1")
+ {#
+ x = begin
+ raise
+ return
+ rescue
+ "OK"
+ else
+ return
+ end
+ };
+ end
+
def test_tautological_condition
assert_valid_syntax("def f() return if false and invalid; nil end")
assert_valid_syntax("def f() return unless true or invalid; nil end")