From fa38a4c3777e667813d15c32f34a6d89df59d4e1 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 22 Aug 2024 17:13:06 +0900 Subject: [PATCH] Avoid multi edges for gvars --- lib/typeprof/core/ast/variable.rb | 1 + scenario/regressions/multi_edge_to_gvar.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 scenario/regressions/multi_edge_to_gvar.rb diff --git a/lib/typeprof/core/ast/variable.rb b/lib/typeprof/core/ast/variable.rb index 309680a3..1c12492f 100644 --- a/lib/typeprof/core/ast/variable.rb +++ b/lib/typeprof/core/ast/variable.rb @@ -192,6 +192,7 @@ def undefine0(genv) def install0(genv) val = @rhs.install(genv) + val = val.new_vertex(genv, self) # avoid multi-edge from val to static_ret.vtx @changes.add_edge(genv, val, @static_ret.vtx) val end diff --git a/scenario/regressions/multi_edge_to_gvar.rb b/scenario/regressions/multi_edge_to_gvar.rb new file mode 100644 index 00000000..e0ffb364 --- /dev/null +++ b/scenario/regressions/multi_edge_to_gvar.rb @@ -0,0 +1,16 @@ +## update +def check + while true + opt = 1 + if cond + $foo = opt + else + $foo = opt + end + end +end + +## assert +class Object + def check: -> nil +end