Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/typeprof/core/builtin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ def array_aset(changes, node, ty, a_args, ret)
else
false
end
elsif a_args.positionals.size == 3
# ary[start, len] = val
# Use SplatBox to extract element types from the assigned value
elem_vtx = case ty
when Type::Array
ty.get_elem(@genv)
when Type::Instance
ty.mod == @genv.mod_ary ? ty.args[0] : nil
end
return false unless elem_vtx
val = a_args.positionals[2]
splat_ret = changes.add_splat_box(@genv, val).ret
changes.add_edge(@genv, splat_ret, elem_vtx)
true
else
false
end
Expand Down
14 changes: 14 additions & 0 deletions scenario/array/slice_aset.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## update
def test
a = [0] * 10
a[0, 3] = [1, 2, 3]
a[5, 3] = a[0, 3]
a[0]
end

test

## assert
class Object
def test: -> Integer
end
Loading