rbs
rbs copied to clipboard
RBS raises NoMethodError when a class inherits a module mistakenly
RBS raises an error when a class inherits a module mistakenly.
# test.rbs
module M
end
class C < M
end
$ rbs -I. validate --silent
/path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/definition_builder.rb:393:in `block (2 levels) in build_singleton': undefined method `defs' for nil:NilClass (NoMethodError)
if new_method.defs.all? {|d| d.defined_in == BuiltinNames::Class.name }
^^^^^
from <internal:kernel>:90:in `tap'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/definition_builder.rb:385:in `block in build_singleton'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/definition_builder.rb:860:in `try_cache'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/definition_builder.rb:376:in `build_singleton'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/cli.rb:443:in `block in run_validate'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/cli.rb:438:in `each'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/cli.rb:438:in `run_validate'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/lib/rbs/cli.rb:130:in `run'
from /path/to/lib/ruby/gems/3.2.0+1/gems/rbs-2.7.0/exe/rbs:7:in `<top (required)>'
from /path/to/bin/rbs:25:in `load'
from /path/to/bin/rbs:25:in `<main>'
The test.rbs is actually invalid, but rbs validate should handle this problem instead of NoMethodError.
The current behavior confuses RBS beginners.