Skip to content

Commit 20f350a

Browse files
committed
Fix wrong index offset for optional positionals with splat args
1 parent b5ef018 commit 20f350a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/typeprof/core/graph/box.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ def pass_arguments(changes, genv, a_args)
519519
end
520520
end
521521
@f_args.opt_positionals.each_with_index do |f_vtx, i|
522-
i += @f_args.opt_positionals.size
522+
i += @f_args.req_positionals.size
523523
if i < start_rest
524524
changes.add_edge(genv, a_args.positionals[i], f_vtx)
525525
else

scenario/args/splat_with_opt.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## update
2+
def foo(a, b, c, o1 = :default)
3+
o1
4+
end
5+
6+
ary = ["str"].to_a
7+
foo(:A, :B, :C, *ary)
8+
9+
## assert
10+
class Object
11+
def foo: (:A, :B, :C, ?:default | String) -> (:default | String)
12+
end

0 commit comments

Comments
 (0)