Skip to content

Commit

Permalink
expect unknown methods to take varargs of top types
Browse files Browse the repository at this point in the history
  • Loading branch information
ptarjan committed Sep 15, 2017
1 parent 93677c9 commit 56d7219
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/rdl/typecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1510,7 +1510,8 @@ def self.lookup(scope, klass, name, e)
# arity right.
method = begin
the_klass.instance_method(name)
rescue NameError
rescue NameError => e
puts "Unknown method: #{the_klass}.#{name}"
nil
end

Expand All @@ -1526,7 +1527,7 @@ def self.lookup(scope, klass, name, e)
args << RDL::Type::VarargType.new(RDL::Globals.types[:top])
end
else
args = []
args = [RDL::Type::VarargType.new(RDL::Globals.types[:top])]
end

ret = RDL::Globals.types[:bot]
Expand Down
17 changes: 17 additions & 0 deletions test/test_typecheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1700,4 +1700,21 @@ def self.bar; 1; end

assert_equal "1", UntypedVararg.foo(1)
end

def test_unknown_method
self.class.class_eval "module UnknownMethod; end"
UnknownMethod.class_eval do
extend RDL::Annotate
type '() -> nil', :typecheck => :call
def self.foo
begin
whatever(5, 4)
rescue
nil
end
end
end

assert_nil UnknownMethod.foo
end
end

0 comments on commit 56d7219

Please sign in to comment.