From aee5c4338bc51f007114ea42d468d01748c123fa Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sun, 10 Jun 2018 05:02:26 +0000 Subject: parse.y: Fix locations of NODE_RESCUE * parse.y (new_bodystmt): Fix locations of NODE_RESCUE to end with nd_else or nd_resq. Before this commit, locations of NODE_RESCUE included locations of nd_ensr of NODE_ENSURE which is a parent node of NODE_RESCUE. e.g. The location of the end of NODE_RESCUE is fixed: ``` def a :b rescue :c ensure :d end ``` * Before ``` NODE_RESCUE (line: 2, location: (2,2)-(6,4)) ``` * After ``` NODE_RESCUE (line: 3, location: (2,2)-(5,0)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index 9b74169eed..0702877f83 100644 --- a/parse.y +++ b/parse.y @@ -10263,7 +10263,11 @@ new_bodystmt(struct parser_params *p, NODE *head, NODE *rescue, NODE *rescue_els { NODE *result = head; if (rescue) { - result = NEW_RESCUE(head, rescue, rescue_else, loc); + NODE *tmp = rescue_else ? rescue_else : rescue; + YYLTYPE rescue_loc = code_loc_gen(&head->nd_loc, &tmp->nd_loc); + + result = NEW_RESCUE(head, rescue, rescue_else, &rescue_loc); + nd_set_line(result, rescue->nd_loc.beg_pos.lineno); } else if (rescue_else) { result = block_append(p, result, rescue_else); -- cgit v1.2.3