You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ cat sample.rb
class A
module B
end
end
class C < A
include B # A::B
end
$ ruby sample.rb
$ rbs prototype rb sample.rb > sample.rbs
$ cat sample.rbs
class A
module B
end
end
class C < A
include B
end
$ rbs -I . validate
...(snip)...
Validating class/module definition: `::A`...
Validating class/module definition: `::A::B`...
Validating class/module definition: `::C`...
/Users/ksss/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rbs-1.3.3/lib/rbs/errors.rb:178:in `check!': t.rbs:7:2...7:11: Could not find mixin: B (RBS::NoMixinFoundError)
Is this intentional?
The text was updated successfully, but these errors were encountered:
Yes, the constant name resolution is intentional. see #307
Type name resolution became more compatible with Ruby's constant resolution. It resolves given relative type names based on class/module nesting structure. Note that the type name resolution does not refer inheritance and includes.
And rbs prototype rb can't generate the expected RBS, such as include A::B, due to the design. It just parses Ruby code but doesn't evaluate, so rbs prototype rb doesn't know the module name's ancestors.
By the way, we can improve two points about the issue.
First, we can write a documentation about module resolution. Probably the docs don't mention this incompatibility. A doc should mention it.
Second, rbs prototype runtime has the same problem but it could be fixed unlike prototype rb. prototype runtime evaluates Ruby code, so it can get the module full name.
$ rbs prototype runtime -R sample.rb A 'A::*''C''C::*'
class A
module B
end
end
class C < A
include B # ← It should be `include A::B`, but isn't.
end
Is this intentional?
The text was updated successfully, but these errors were encountered: