summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-10 05:02:26 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-10 05:02:26 +0000
commitaee5c4338bc51f007114ea42d468d01748c123fa (patch)
tree3d1d14622acf2281b919ce52312469f2abd7d9d7 /parse.y
parentd89d4e93afefa30137ed64c1efbd3750f76b6112 (diff)
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
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y6
1 files changed, 5 insertions, 1 deletions
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);