summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-25 01:39:45 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-25 01:39:45 +0000
commitce64157d970c57788f43cc35b48ebf8ebbd7d051 (patch)
tree4423bf474e46d138fd383a2d4a80395daf3738c2 /parse.y
parent6240f583535505479e2d80ba354711ddb468fe29 (diff)
downloadruby-ce64157d970c57788f43cc35b48ebf8ebbd7d051.tar.gz
parse.y: Fix a location of assignable nodes
* parse.y (new_op_assign_gen): Update the location of lhs when NODE_OP_ASGN_OR/NODE_OP_ASGN_AND are generated. When NODE_OP_ASGN_OR/NODE_OP_ASGN_AND are generated a nd_value of lhs is set, so it is needed to update a location of lhs to include a location of rhs (same as node_assign_gen). e.g. The locations of NODE_DASGN_CURR is fixed: ``` a ||= 1 ``` * Before ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) ``` * After ``` NODE_DASGN_CURR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 7) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y10
1 files changed, 6 insertions, 4 deletions
diff --git a/parse.y b/parse.y
index 642e26d244..2961a33166 100644
--- a/parse.y
+++ b/parse.y
@@ -10858,10 +10858,11 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, con
if (lhs) {
ID vid = lhs->nd_vid;
- YYLTYPE *lhs_location = &lhs->nd_loc;
+ YYLTYPE lhs_location = lhs->nd_loc;
if (op == tOROP) {
lhs->nd_value = rhs;
- asgn = NEW_OP_ASGN_OR(gettable(vid, lhs_location), lhs);
+ lhs->nd_loc = *location;
+ asgn = NEW_OP_ASGN_OR(gettable(vid, &lhs_location), lhs);
asgn->nd_loc = *location;
if (is_notop_id(vid)) {
switch (id_type(vid)) {
@@ -10874,12 +10875,13 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, con
}
else if (op == tANDOP) {
lhs->nd_value = rhs;
- asgn = NEW_OP_ASGN_AND(gettable(vid, lhs_location), lhs);
+ lhs->nd_loc = *location;
+ asgn = NEW_OP_ASGN_AND(gettable(vid, &lhs_location), lhs);
asgn->nd_loc = *location;
}
else {
asgn = lhs;
- asgn->nd_value = new_call(gettable(vid, lhs_location), op, new_list(rhs, &rhs->nd_loc), location);
+ asgn->nd_value = new_call(gettable(vid, &lhs_location), op, new_list(rhs, &rhs->nd_loc), location);
asgn->nd_loc = *location;
}
}