Fix RBS::ParsingError when block argument is assigned to rest keywords hash#358
Open
sinsoku wants to merge 1 commit intoruby:masterfrom
Open
Fix RBS::ParsingError when block argument is assigned to rest keywords hash#358sinsoku wants to merge 1 commit intoruby:masterfrom
sinsoku wants to merge 1 commit intoruby:masterfrom
Conversation
…s hash
The following code caused RBS::ParsingError:
```ruby
# issue.rb
def foo(**opts, &block)
opts[:callback] = block
opts
end
foo(key: 1) {}
```
```bash
$ bin/typeprof issue.rb
# TypeProf 0.31.1
# issue.rb
/Users/sinsoku/.local/share/mise/installs/ruby/4.0.0/lib/ruby/gems/4.0.0/gems/rbs-3.10.0/lib/rbs/parser_aux.rb:10:in 'RBS::Parser._parse_type': RBS::ParsingError
from /Users/sinsoku/.local/share/mise/installs/ruby/4.0.0/lib/ruby/gems/4.0.0/gems/rbs-3.10.0/lib/rbs/parser_aux.rb:10:in 'RBS::Parser.parse_type'
from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/type.rb:20:in 'TypeProf::Core::Type.extract_hash_value_type'
from /Users/sinsoku/ghq/github.com/ruby/typeprof/lib/typeprof/core/graph/box.rb:647:in 'TypeProf::Core::MethodDefBox#show'
```
Type::Proc#show returned "<Proc>" which is not valid RBS syntax.
MethodDefBox#show calls extract_hash_value_type to parse rest_keywords
type with RBS::Parser, causing ParsingError when the type contains "<Proc>".
Changed Type::Proc#show to return "Proc" for RBS compatibility.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following code caused RBS::ParsingError:
Type::Proc#show returned
<Proc>which is not valid RBS syntax.MethodDefBox#show calls extract_hash_value_type to parse rest_keywords
type with RBS::Parser, causing ParsingError when the type contains
<Proc>.Changed Type::Proc#show to return
Procfor RBS compatibility.🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com