Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prime's signature is broken #924

Closed
ksss opened this issue Mar 17, 2022 · 2 comments · Fixed by #934
Closed

Prime's signature is broken #924

ksss opened this issue Mar 17, 2022 · 2 comments · Fixed by #934

Comments

@ksss
Copy link
Collaborator

ksss commented Mar 17, 2022

In steep check show ModuleSelfTypeError in prime.rbs if import prime signature.

../../../../.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/rbs-2.2.2/stdlib/prime/0/prime.rbs:47:2: [error] Module self type constraint in type `::Prime` doesn't satisfy: `::Prime <: ::_Each[::Integer]`
│ Diagnostic ID: RBS::ModuleSelfTypeError
│
└   include Enumerable[Integer]
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Prime.each
Prime.instance.each # Ruby::NoMethod (Type `::Prime` does not have method `each`)

In prime.rbs defined each method with self? prefix.

def self?.each: (?Integer? ubound, ?PseudoPrimeGenerator generator) { (Integer) -> void } -> void
| (?Integer? ubound, ?PseudoPrimeGenerator generator) -> PseudoPrimeGenerator

The documentation states the following.
https://github.com/ruby/rbs/blob/master/docs/syntax.md#method-definition

self? method definition adds two methods: a public singleton method and a private instance method, which is equivalent to module_function in Ruby.

Is self? intentional?
Is this an rbs problem? Or is it a steep problem?

@soutaro
Copy link
Member

soutaro commented Mar 22, 2022

Nice catch!

I'm sorry for the error. This problem is occurred by the change of the semantics of self? syntax. It was to define two methods, with the same visibility.

I think we need two defs, for public singleton method and public instance method respectively.

@ksss
Copy link
Collaborator Author

ksss commented Mar 22, 2022

Thank you for the response.
Fixed ✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants