'RBS::Types::Proc#map_type_name': undefined method 'map_type_name' for an instance of RBS::Types::UntypedFunction (NoMethodError)

Open
#2,066 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
ruby
Domain
devtools

Research direction

Start with lib/rbs/types.rb around RBS::Types::Proc#map_type_name, then follow the stack through lib/rbs/environment.rb and the validate entry point. Reproduce the issue with rbs -Isig validate using the sample signature. Done means the documented untyped-parameter Proc syntax validates without raising NoMethodError.

Written by the indexing model from the issue text.

Description

Hey, not sure if this is meant to be valid or not, but while trying to write various tests I came across this sample which errors on rbs -Isig validate:

class Foo
  def t: -> (^(?) -> void)
end

I believe it's valid syntax (from the docs), but correct me if I'm wrong on that.

_proc_ ::= `^` _parameters?_ _self-type-binding?_ _block?_ `->` _type_
         | `^` `(` `?` `)` `->` _type_                                   # Proc type with untyped parameter

I'm using Ruby 3.4.0-preview2, and RBS 3.6.1.

The stack trace is:

/Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/types.rb:1428:in 'RBS::Types::Proc#map_type_name': undefined method 'map_type_name' for an instance of RBS::Types::UntypedFunction (NoMethodError)

          type: type.map_type_name(&block),
                    ^^^^^^^^^^^^^^
Did you mean?  map_type
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:793:in 'RBS::Environment#absolute_type'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:775:in 'block in RBS::Environment#resolve_method_type'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/types.rb:1002:in 'RBS::Types::Function#map_type'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/method_type.rb:66:in 'RBS::MethodType#map_type'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:774:in 'RBS::Environment#resolve_method_type'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:681:in 'block in RBS::Environment#resolve_member'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:679:in 'Array#map'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:679:in 'RBS::Environment#resolve_member'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:570:in 'block in RBS::Environment#resolve_declaration'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:567:in 'Array#map'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:567:in 'RBS::Environment#resolve_declaration'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:512:in 'block (2 levels) in RBS::Environment#resolve_type_names'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:508:in 'Array#map'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:508:in 'block in RBS::Environment#resolve_type_names'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:500:in 'Hash#each'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/environment.rb:500:in 'RBS::Environment#resolve_type_names'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/cli/validate.rb:53:in 'RBS::CLI::Validate#initialize'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/cli.rb:447:in 'Class#new'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/cli.rb:447:in 'RBS::CLI#run_validate'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/lib/rbs/cli.rb:140:in 'RBS::CLI#run'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/lib/ruby/gems/3.4.0+0/gems/rbs-3.6.1/exe/rbs:7:in '<top (required)>'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/bin/rbs:25:in 'Kernel#load'
	from /Users/hjwylde/.asdf/installs/ruby/3.4.0-preview2/bin/rbs:25:in '<main>'
Dominant language
Ruby
Stars
2.2k
Forks
263
Avg merge
1d 20h
Merged PRs (30d)
64

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/rbs

All issues in ruby/rbs

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.