mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #2099 from nobu/optional_arguments_in_rhs
Optional arguments in rhs
This commit is contained in:
+3
-4
@@ -3061,14 +3061,13 @@ f_opt_asgn : tIDENTIFIER '='
|
||||
|
||||
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), $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