diff options
| author | nagachika <nagachika@ruby-lang.org> | 2024-02-25 11:52:05 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2024-02-25 11:52:05 +0900 |
| commit | 24dd529750c08b5603fb418a4f34998b9bf6c8f9 (patch) | |
| tree | 533a61f12b061263d1129a726dfc7b5310d5d0e3 /parse.y | |
| parent | 3960d894d98d20540e646a0d6c2186a2d676b96c (diff) | |
merge revision(s) c8d162c889008028b148437d02f36f4edaa749fd: [Backport #19973]
[Bug #19973] Warn duplicated keyword arguments after keyword splat
---
parse.y | 11 +++++++----
test/ruby/test_syntax.rb | 6 ++++++
2 files changed, 13 insertions(+), 4 deletions(-)
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -12889,15 +12889,17 @@ remove_duplicate_keys(struct parser_params *p, NODE *hash) NODE *result = 0; NODE *last_expr = 0; rb_code_location_t loc = hash->nd_loc; - while (hash && hash->nd_head && hash->nd_next) { + while (hash && hash->nd_next) { NODE *head = hash->nd_head; NODE *value = hash->nd_next; NODE *next = value->nd_next; st_data_t key = (st_data_t)head; st_data_t data; value->nd_next = 0; - if (nd_type_p(head, NODE_LIT) && - st_delete(literal_keys, (key = (st_data_t)head->nd_lit, &key), &data)) { + if (!head) { + } + else if (nd_type_p(head, NODE_LIT) && + st_delete(literal_keys, (key = (st_data_t)head->nd_lit, &key), &data)) { NODE *dup_value = ((NODE *)data)->nd_next; rb_compile_warn(p->ruby_sourcefile, nd_line((NODE *)data), "key %+"PRIsVALUE" is duplicated and overwritten on line %d", @@ -12910,7 +12912,7 @@ remove_duplicate_keys(struct parser_params *p, NODE *hash) } } st_insert(literal_keys, (st_data_t)key, (st_data_t)hash); - last_expr = nd_type_p(head, NODE_LIT) ? value : head; + last_expr = !head || nd_type_p(head, NODE_LIT) ? value : head; hash = next; } st_foreach(literal_keys, append_literal_keys, (st_data_t)&result); |
