Open thomthom opened 2 years ago
Not currently, sorry... I'm not sure how exactly this could be encoded either, since I'm not aware of any way to specify this in YARD. Looking up the type of #each
feels possible but a bit hacky and fragile! Do you have any suggestions?
I also met a similar case with Struct
.
Input:
require 'struct'
Foo = Struct.new(:bar)
Generated:
class Foo < Struct
# Returns the value of attribute bar
attr_accessor bar: Object
end
Result of rbs validate
command:
/Users/tkomiya/.dotfiles/_rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rbs-3.1.1/lib/rbs/errors.rb:90:in `check!': sig/sord.rbs:1:0...4:3: ::Struct expects parameters [Elem], but given args [] (RBS::InvalidTypeApplicationError)
It would be nice if we can give a hint to the sord via comments or annotations.
Given a class that implement Enumerable:
The generated output is:
If I then run
steep check
on this I get errors:If I alter the RBS to include a param for the
Enumerable
:Then it passes:
I'm not actually 100% sure what param to give Enumerable in the case of each yielding key and value params. hence the
untyped
in this case. But given that you have a collection object that returnString
objects, then I presume it should beinclude Enumerable[String]
. (?) Is there a way I can makesord
generate an RBS that will not cause an error insteep
?