steep icon indicating copy to clipboard operation
steep copied to clipboard

extend module in RBS sig not declaring module instance methods as singleton methods of extended module

Open HoneyryderChuck opened this issue 8 months ago • 5 comments

This can be tested with the following code:

module B
  def foo
    "foo"
  end
end

module A
  module_function

  extend B

  def bar
    foo
  end
end

A.bar
module B
  def foo: () -> String
end

module A
  extend B

  def self?.bar: () -> String
end

this produces the following steep error:

Type `(::Object & ::A)` does not have method `foo` (Ruby::NoMethod)

I checked that, in latest rbs, foo does get added as a singleton method of module A, so it should be available for steep to use.

HoneyryderChuck avatar Mar 26 '25 11:03 HoneyryderChuck

I could not reproduce the problem in my environment. Please let me know your environment.

My environment is here.

* rbs (3.9.1)
* steep (1.10.0)

ksss avatar Mar 26 '25 13:03 ksss

@ksss you're right, updated the example. was under the impression that the outer call would also fail, but it seems that the error only pops up if using the function from another module function.

HoneyryderChuck avatar Apr 01 '25 15:04 HoneyryderChuck

Since def bar appears to be an instance method, foo also looks like an instance method call. The warning seems to be correct.

Image

ksss avatar Apr 03 '25 01:04 ksss

again, my bad. Corrected. The module_function call was missing. same outcome.

HoneyryderChuck avatar Apr 03 '25 21:04 HoneyryderChuck

Thank you, I reproduced it.

Perhaps steep is not able to support module_function. Supporting it would solve this issue.

ksss avatar Apr 04 '25 04:04 ksss