From 367118b1b678b83869a9106191cb85197c9ef525 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Mon, 21 Apr 2014 10:48:00 +0900 Subject: fix optional arguments in rhs define optional arguments as argument variables in the rhs default expressions, as same as mere assignment expressions. Import ruby/ruby@01740f0c273c89f7bcff3d5014d73c8ff6fb1986 --- src/parse.y | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 1a3dadd61..fab6397e6 100644 --- a/src/parse.y +++ b/src/parse.y @@ -1075,7 +1075,7 @@ heredoc_end(parser_state *p) %type brace_block cmd_brace_block do_block lhs none f_bad_arg %type mlhs mlhs_list mlhs_post mlhs_basic mlhs_item mlhs_node mlhs_inner %type fsym sym basic_symbol operation operation2 operation3 -%type cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg +%type cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_opt_asgn %type heredoc words symbols %token tUPLUS /* unary+ */ @@ -3052,10 +3052,16 @@ f_arg : f_arg_item } ; -f_opt : tIDENTIFIER '=' arg_value +f_opt_asgn : tIDENTIFIER '=' { local_add_f(p, $1); - $$ = cons(nsym($1), $3); + $$ = $1; + } + ; + +f_opt : f_opt_asgn arg_value + { + $$ = cons(nsym($1), $2); } ; -- cgit v1.2.3