Skip to content

Commit 598fa1f

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 598fa1f

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

lib/typeprof/core/graph/box.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ def run0(genv, changes)
380380
@hsh.each_type do |ty|
381381
ty = ty.base_type(genv)
382382
if ty.mod == genv.mod_hash
383-
changes.add_edge(genv, ty.args[0], @unified_key)
384-
changes.add_edge(genv, ty.args[1], @unified_val)
383+
changes.add_edge(genv, ty.args[0].new_vertex(genv, :__hash_splat), @unified_key)
384+
changes.add_edge(genv, ty.args[1].new_vertex(genv, :__hash_splat), @unified_val)
385385
else
386386
"???"
387387
end
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)