parse.y: Set locations of nd_body in NODE_ITER explicitly

* parse.y: Currently the location of do_body is set
  by new_do_body. Sometimes the last part of do_body is
  none, because bodystmt ends with opt_ensure.
  Token keyword_end has been looked ahead when a tokenizer
  generates none, so the last location of opt_ensure matches
  the last location of `end`. But this relation will be
  broken when we change the last location of none to be equal to
  the first location of none. So set locations of nd_body in
  NODE_ITER explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61168 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yui-knk 2017-12-12 14:10:23 +00:00
parent 89c7e6de44
commit 46e8a8ae37

View File

@ -3648,6 +3648,8 @@ do_block : keyword_do_block
{
$$ = $3;
/*%%%*/
$3->nd_body->nd_loc.first_loc = @1.first_loc;
$3->nd_body->nd_loc.last_loc = @4.last_loc;
nd_set_line($$, $<num>2);
/*% %*/
}
@ -3816,6 +3818,8 @@ brace_block : '{'
{
$$ = $3;
/*%%%*/
$3->nd_body->nd_loc.first_loc = @1.first_loc;
$3->nd_body->nd_loc.last_loc = @4.last_loc;
nd_set_line($$, $<num>2);
/*% %*/
}