summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-09-04 12:00:25 -0700
committerJeremy Evans <code@jeremyevans.net>2019-09-05 09:57:43 -0700
commitc6464c44c02fdbb597ca8027af0bc0db28d56f66 (patch)
tree4dd58e5df6c2da614521896bcda233566f0be769 /parse.y
parent1d5066efb08cbb328ba528a5f8be1708584b659f (diff)
Fix code locations of array node inside hash node when multiple kw splats
This is broken at least since 2.5 (I didn't check earlier versions). It resulted in failure in test_ast.rb when the tests were added before the parser change. Basically, in remove_duplicate_keys, if the node is modified, set the location information to the previous location information. The removal of keys should not affect the location in the code.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2428
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y2
1 files changed, 2 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 9003f80d92..63d8f53c1d 100644
--- a/parse.y
+++ b/parse.y
@@ -11336,6 +11336,7 @@ remove_duplicate_keys(struct parser_params *p, NODE *hash)
{
st_table *literal_keys = st_init_numtable_with_size(hash->nd_alen / 2);
NODE *result = 0;
+ rb_code_location_t loc = hash->nd_loc;
while (hash && hash->nd_head && hash->nd_next) {
NODE *head = hash->nd_head;
NODE *value = hash->nd_next;
@@ -11361,6 +11362,7 @@ remove_duplicate_keys(struct parser_params *p, NODE *hash)
if (!result) result = hash;
else list_concat(result, hash);
}
+ result->nd_loc = loc;
return result;
}