Commit 8694654f authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2099 from nobu/optional_arguments_in_rhs

Optional arguments in rhs
parents 6ec04a4e ac6747a9
...@@ -3061,14 +3061,13 @@ f_opt_asgn : tIDENTIFIER '=' ...@@ -3061,14 +3061,13 @@ f_opt_asgn : tIDENTIFIER '='
f_opt : f_opt_asgn arg_value f_opt : f_opt_asgn arg_value
{ {
$$ = cons(nsym($1), $2); $$ = cons(nsym($1), $2);
} }
; ;
f_block_opt : tIDENTIFIER '=' primary_value f_block_opt : f_opt_asgn primary_value
{ {
local_add_f(p, $1); $$ = cons(nsym($1), $2);
$$ = cons(nsym($1), $3);
} }
; ;
......
...@@ -289,3 +289,7 @@ assert('optional argument in the rhs default expressions') do ...@@ -289,3 +289,7 @@ assert('optional argument in the rhs default expressions') do
assert_nil(o.t) assert_nil(o.t)
assert_equal("method called", o.t2) assert_equal("method called", o.t2)
end 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