summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_syntax.rb7
2 files changed, 9 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;
}
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index 56e2937dc8..a904b0dc3a 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -125,6 +125,13 @@ class TestSyntax < Test::Unit::TestCase
assert_equal([kw], [kw, **kw, **kw])
assert_equal([h], [h, **kw, **kw])
assert_equal([h, h], [h, **kw, **kw, **h])
+
+ assert_equal([h, {:a=>2}], [h, **{}, **h, a: 2])
+ assert_equal([h, h], [h, **{}, a: 2, **h])
+ assert_equal([h, h], [h, a: 2, **{}, **h])
+ assert_equal([h, h], [h, a: 2, **h, **{}])
+ assert_equal([h, {:a=>2}], [h, **h, a: 2, **{}])
+ assert_equal([h, {:a=>2}], [h, **h, **{}, a: 2])
end
def test_normal_argument