Commit ac6747a9 authored by Nobuyoshi Nakada's avatar Nobuyoshi Nakada

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@01740f0c273c89f7bcff3d5014d73c8ff6fb1986
parent 28f6cfe4
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment