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
1 change: 1 addition & 0 deletions lib/rbs/test/type_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def value(val, type)
value(val, builder.expand_alias2(type.name.absolute!, type.args))
when Types::Tuple
Test.call(val, IS_AP, ::Array) &&
type.types.length == val.length &&
type.types.map.with_index {|ty, index| value(val[index], ty) }.all?
when Types::Record
Test::call(val, IS_AP, ::Hash) &&
Expand Down
2 changes: 1 addition & 1 deletion stdlib/objspace/0/objspace.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ module ObjectSpace
# ObjectSpace.reachable_objects_from(1)
# #=> nil # 1 is not markable (heap managed) object
#
def self?.reachable_objects_from: (untyped) -> ([ untyped ] | nil)
def self?.reachable_objects_from: (untyped) -> (Array[untyped] | nil)

# <!--
# rdoc-file=ext/objspace/objspace.c
Expand Down
4 changes: 4 additions & 0 deletions test/rbs/test/type_check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def to_int: () -> Integer
refute typecheck.value(nil, parse_type("bool"))
refute typecheck.value("", parse_type("bool"))
refute typecheck.value(BasicObject.new, parse_type("bool"))

assert typecheck.value([1], parse_type("[Integer]"))
refute typecheck.value([], parse_type("[Integer]"))
refute typecheck.value([1, 2], parse_type("[Integer]"))
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/stdlib/ObjectSpace_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ def test_memsize_of_all
end

def test_reachable_objects_from
assert_send_type "(untyped) -> [untyped]",
assert_send_type "(untyped) -> Array[untyped]",
ObjectSpace, :reachable_objects_from, "dummy"
assert_send_type "(untyped) -> [untyped]",
assert_send_type "(untyped) -> Array[untyped]",
ObjectSpace, :reachable_objects_from, ["dummy", "dummy2"]
assert_send_type "(untyped) -> nil",
ObjectSpace, :reachable_objects_from, nil
Expand Down