aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-16 23:13:24 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-16 23:13:24 +0000
commit2fb759bc17247255b1c5ceac0deb8a4083a1cfa5 (patch)
treecaa171e5e852903c269814f68b194921251723e6
parentd6d10679e03cd01652483eb45fa31410b42c808d (diff)
downloadruby-2fb759bc17247255b1c5ceac0deb8a4083a1cfa5.tar.gz
Fix location of NODEs generated by new_op_assign_gen
* parse.y (new_op_assign_gen): Use a location of lhs when call gettable, bacause gettable creates a variable node. Use a location of rhs when call new_list, because item of new_list is rhs. The locations of NODE_DVAR(nd_vid: :a) and NODE_ARRAY are fixed: ``` a -= 1 ``` * Before ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) NODE_ARRAY (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 6) ``` * After ``` NODE_DVAR (line: 1, first_lineno: 1, first_column: 0, last_lineno: 1, last_column: 1) NODE_ARRAY (line: 1, first_lineno: 1, first_column: 5, last_lineno: 1, last_column: 6) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y7
1 files changed, 4 insertions, 3 deletions
diff --git a/parse.y b/parse.y
index c3756c52a3..6a0f5045db 100644
--- a/parse.y
+++ b/parse.y
@@ -10861,9 +10861,10 @@ 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;
if (op == tOROP) {
lhs->nd_value = rhs;
- asgn = NEW_OP_ASGN_OR(gettable(vid, location), lhs);
+ asgn = NEW_OP_ASGN_OR(gettable(vid, lhs_location), lhs);
asgn->nd_loc = *location;
if (is_notop_id(vid)) {
switch (id_type(vid)) {
@@ -10876,12 +10877,12 @@ 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, location), lhs);
+ asgn = NEW_OP_ASGN_AND(gettable(vid, lhs_location), lhs);
asgn->nd_loc = *location;
}
else {
asgn = lhs;
- asgn->nd_value = new_call(gettable(vid, location), op, new_list(rhs, location), location);
+ asgn->nd_value = new_call(gettable(vid, lhs_location), op, new_list(rhs, &rhs->nd_loc), location);
asgn->nd_loc = *location;
}
}