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:
Nobuyoshi Nakada
2014-04-21 14:55:06 +09:00
parent 28f6cfe424
commit ac6747a9c5
2 changed files with 6 additions and 3 deletions
+2 -3
View File
@@ -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);
}
;
+4
View File
@@ -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