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

rbs validate: NoMethodError for a method taking a block #1905

Closed
tk0miya opened this issue Jun 23, 2024 · 1 comment
Closed

rbs validate: NoMethodError for a method taking a block #1905

tk0miya opened this issue Jun 23, 2024 · 1 comment

Comments

@tk0miya
Copy link
Contributor

tk0miya commented Jun 23, 2024

I got NoMethodError from the following RBS file when I run rbs validate:

class Object
  def foo: () { (?) -> untyped } -> nil
end
$ bundle exec rbs -Isig validate
bundler: failed to load command: rbs (/Users/tkomiya/.rbenv/versions/3.3.2/bin/rbs)
/Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/method_type.rb:134:in `with_nonreturn_void?': undefined method `with_nonreturn_void?' for an instance of RBS::Types::UntypedFunction (NoMethodError)

          block.type.with_nonreturn_void? || block.self_type&.with_nonreturn_void? || false
                    ^^^^^^^^^^^^^^^^^^^^^
Did you mean?  with_nonreturn_void
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:274:in `void_type_context_validator'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:155:in `block (4 levels) in validate_class_module_definition'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:154:in `each'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:154:in `block (3 levels) in validate_class_module_definition'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/ast/declarations.rb:14:in `block in each_member'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/ast/declarations.rb:12:in `each'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/ast/declarations.rb:12:in `each_member'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:150:in `block (2 levels) in validate_class_module_definition'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:149:in `each'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:149:in `block in validate_class_module_definition'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:97:in `each'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:97:in `validate_class_module_definition'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli/validate.rb:84:in `run'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli.rb:447:in `run_validate'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/lib/rbs/cli.rb:140:in `run'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/rbs-3.5.1/exe/rbs:7:in `<top (required)>'
	from /Users/tkomiya/.rbenv/versions/3.3.2/bin/rbs:25:in `load'
	from /Users/tkomiya/.rbenv/versions/3.3.2/bin/rbs:25:in `<top (required)>'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `load'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:58:in `kernel_load'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/cli/exec.rb:23:in `run'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/cli.rb:451:in `exec'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/cli.rb:34:in `dispatch'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/cli.rb:28:in `start'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/exe/bundle:28:in `block in <top (required)>'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
	from /Users/tkomiya/.dotfiles/_rbenv/versions/3.3.2/lib/ruby/gems/3.3.0/gems/bundler-2.5.3/exe/bundle:20:in `<top (required)>'
	from /Users/tkomiya/.rbenv/versions/3.3.2/bin/bundle:25:in `load'
	from /Users/tkomiya/.rbenv/versions/3.3.2/bin/bundle:25:in `<main>'

This RBS definition is generated from the following Ruby code via rbs prototype rb command.

def foo(&block)
end

Note: I got this error when I updated rbs to 3.5.1 from 3.4.4.

Here is a minimal reproducible example: https://github.com/tk0miya/rbs_validate_with_nonreturn_void_bug/tree/main

tk0miya added a commit to tk0miya/rbs that referenced this issue Jun 23, 2024
The method name was incorrect. `#with_nonreturn_void` should be renamed
to `#with_nonreturn_void?`.
github-merge-queue bot pushed a commit that referenced this issue Jul 10, 2024
Fix #1905: Fix typo in UntypedFunction
soutaro pushed a commit to tk0miya/rbs that referenced this issue Jul 10, 2024
The method name was incorrect. `#with_nonreturn_void` should be renamed
to `#with_nonreturn_void?`.
github-merge-queue bot pushed a commit that referenced this issue Jul 10, 2024
Fix #1905: Fix typo in UntypedFunction
soutaro added a commit that referenced this issue Jul 10, 2024
Fix #1905: Fix typo in UntypedFunction
@soutaro
Copy link
Member

soutaro commented Jul 10, 2024

Fixed in #1905. Thanks! 🙏

@soutaro soutaro closed this as completed Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants