steep icon indicating copy to clipboard operation
steep copied to clipboard

`steep check`: anonymous Module considered to be a part of the class

Open palkan opened this issue 5 years ago • 0 comments

Example:

# a.rb
class A
  def foo
    "bar"
  end

  Module.new do
    def foo(bar)
      bar.size
    end
  end
end

# a.rbs
class A
  def foo: -> String
end

Running steep check results in MethodArityMismatch:

steep check
[Steep 0.36.0] [target=lib] [target#type_check(target_sources: [a.rb], validate_signatures: true)] [path=a.rb] [synthesize:(1:1)] [synthesize:(2:3)] [synthesize:(6:3)] [() -> ::Module] [synthesize:(7:5)] [synthesize:(7:13)] Unknown arg type: (arg bar@1)
[Steep 0.36.0] [target=lib] [target#type_check(target_sources: [a.rb], validate_signatures: true)] [path=a.rb] [synthesize:(1:1)] [synthesize:(2:3)] [synthesize:(6:3)] [() { (::Module) -> untyped } -> ::Module] [synthesize:(7:5)] [synthesize:(7:13)] Unknown arg type: (arg bar@1)
a.rb:7:4: MethodArityMismatch: method=foo (def foo(bar))

(The actual use-case was using an anonymous refinements within a class).

palkan avatar Dec 07 '20 11:12 palkan