ruby-changes:48955
From: yui-knk <ko1@a...>
Date: Fri, 8 Dec 2017 09:33:44 +0900 (JST)
Subject: [ruby-changes:48955] yui-knk:r61074 (trunk): parse.y: Fix locations of modifier_rescue
yui-knk 2017-12-08 09:33:38 +0900 (Fri, 08 Dec 2017) New Revision: 61074 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61074 Log: parse.y: Fix locations of modifier_rescue * parse.y: Fix to only include a range from modifier_rescue to stmt (or arg). e.g. The locations of the NODE_RESBODY is fixed: ``` a rescue 1 ``` * Before ``` NODE_RESBODY (line: 1, code_range: (1,0)-(1,10)) ``` * After ``` NODE_RESBODY (line: 1, code_range: (1,2)-(1,10)) ``` Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 61073) +++ parse.y (revision 61074) @@ -1453,7 +1453,10 @@ stmt : keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1453 | stmt modifier_rescue stmt { /*%%%*/ - NODE *resq = new_resbody(0, remove_begin($3), 0, &@$); + YYLTYPE location; + location.first_loc = @2.first_loc; + location.last_loc = @3.last_loc; + NODE *resq = new_resbody(0, remove_begin($3), 0, &location); $$ = new_rescue(remove_begin($1), resq, 0, &@$); /*% $$ = dispatch2(rescue_mod, $1, $3); @@ -1572,8 +1575,11 @@ command_rhs : command_call %prec tOP_A https://github.com/ruby/ruby/blob/trunk/parse.y#L1575 | command_call modifier_rescue stmt { /*%%%*/ + YYLTYPE location; + location.first_loc = @2.first_loc; + location.last_loc = @3.last_loc; value_expr($1); - $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &@$), 0, &@$); + $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &location), 0, &@$); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -2423,8 +2429,11 @@ arg_rhs : arg %prec tOP_ASGN https://github.com/ruby/ruby/blob/trunk/parse.y#L2429 | arg modifier_rescue arg { /*%%%*/ + YYLTYPE location; + location.first_loc = @2.first_loc; + location.last_loc = @3.last_loc; value_expr($1); - $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &@$), 0, &@$); + $$ = new_rescue($1, new_resbody(0, remove_begin($3), 0, &location), 0, &@$); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/