Skip to content

Commit c96385e

Browse files
mamesinsoku
andcommitted
Fix RuntimeError when using multiple hash splat operators
When multiple hash splat operators expand hashes of the same type, duplicate edges were being added to the same vertex, causing `Set#<<` to raise an error. This can be avoided by using `Vertex#new_vertex`. Co-Authored-By: Takumi Shotoku <sinsoku.listy@gmail.com>
1 parent 6e046db commit c96385e

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

lib/typeprof/core/ast/value.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def install0(genv)
307307
h = val.install(genv)
308308
end
309309
# TODO: do we want to call to_hash on h?
310-
@changes.add_hash_splat_box(genv, h, unified_key, unified_val)
310+
@changes.add_hash_splat_box(genv, h, unified_key.new_vertex(genv, self), unified_val.new_vertex(genv, self))
311311
end
312312
end
313313
if @splat
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## update
2+
def opts(prefix)
3+
{ "#{prefix}_key" => 1 }
4+
end
5+
6+
def test
7+
{
8+
**opts(:cat),
9+
**opts(:dog)
10+
}
11+
end

0 commit comments

Comments
 (0)