From 46e8a8ae379bdf0795eb60e8cf22a20457272d02 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Tue, 12 Dec 2017 14:10:23 +0000 Subject: [PATCH] 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 --- parse.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/parse.y b/parse.y index 1026d5c896..7d0f96de41 100644 --- a/parse.y +++ b/parse.y @@ -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($$, $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($$, $2); /*% %*/ }