mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
fix optional block arguments in rhs
define optional block arguments as argument variables in the rhs default expressions, as same as mere assignment expressions. Import ruby/ruby@01740f0c27
This commit is contained in:
+2
-3
@@ -3065,10 +3065,9 @@ f_opt : f_opt_asgn arg_value
|
||||
}
|
||||
;
|
||||
|
||||
f_block_opt : tIDENTIFIER '=' primary_value
|
||||
f_block_opt : f_opt_asgn primary_value
|
||||
{
|
||||
local_add_f(p, $1);
|
||||
$$ = cons(nsym($1), $3);
|
||||
$$ = cons(nsym($1), $2);
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -289,3 +289,7 @@ assert('optional argument in the rhs default expressions') do
|
||||
assert_nil(o.t)
|
||||
assert_equal("method called", o.t2)
|
||||
end
|
||||
|
||||
assert('optional block argument in the rhs default expressions') do
|
||||
assert_nil(proc {|foo = foo| foo}.call)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user