Skip to content

Commit

Permalink
Merge pull request #545 from soutaro/to_a
Browse files Browse the repository at this point in the history
Remove `to_a` error message
  • Loading branch information
soutaro committed May 2, 2022
2 parents b9319d8 + 71de020 commit 4982699
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/steep/type_construction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3986,6 +3986,11 @@ def try_tuple_type(node, hint)
end

def try_convert(type, method)
case type
when AST::Types::Any, AST::Types::Bot, AST::Types::Top, AST::Types::Var
return
end

interface = checker.factory.interface(type, private: false)
if entry = interface.methods[method]
method_type = entry.method_types.find do |method_type|
Expand Down
26 changes: 26 additions & 0 deletions test/type_construction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8673,6 +8673,32 @@ def to_a: () -> Array[T]
end
end

def test_to_a_untyped
with_checker(<<-RBS) do |checker|
RBS

source = parse_ruby(<<-'RUBY')
# @type var a: untyped
a = _ = nil
[*a]
# @type var b: top
b = _ = nil
[*b]
# @type var c: bot
c = _ = nil
[*c]
RUBY

with_standard_construction(checker, source) do |construction, typing|
_, constr = construction.synthesize(source.node)

assert_no_error typing
end
end
end

def test_case_const_unexpected_error
with_checker(<<-RBS) do |checker|
class UnexpectedErrorTest
Expand Down

0 comments on commit 4982699

Please sign in to comment.