Skip to content

Fix NoMethodError in SigTySingletonNode#show due to uninitialized @args#430

Merged
mame merged 2 commits intoruby:masterfrom
sinsoku:fix-singleton-show-nil-args
Apr 28, 2026
Merged

Fix NoMethodError in SigTySingletonNode#show due to uninitialized @args#430
mame merged 2 commits intoruby:masterfrom
sinsoku:fix-singleton-show-nil-args

Conversation

@sinsoku
Copy link
Copy Markdown
Collaborator

@sinsoku sinsoku commented Apr 10, 2026

SigTySingletonNode#initialize did not initialize @Args, causing
a NoMethodError when #show was called during return type checking.
This occurred when a method annotated with singleton(X) returned
a mismatched type.

SigTySingletonNode#initialize did not initialize @Args, causing
a NoMethodError when #show was called during return type checking.
This occurred when a method annotated with singleton(X) returned
a mismatched type.
@mame
Copy link
Copy Markdown
Member

mame commented Apr 16, 2026

Thank you. It seems that RBS::Types::ClassSingleton#args was added in RBS 4.0. I wonder whether we should require rbs >= 4.0.0, or branch using respond_to? instead.

@sinsoku
Copy link
Copy Markdown
Collaborator Author

sinsoku commented Apr 18, 2026

Thank you for the review.

Since RBS 4.0 was recently released, I think we should maintain compatibility with RBS 3.x for now. I've updated the code to use respond_to?(:args) to avoid errors on RBS 3.x.

Copy link
Copy Markdown
Member

@mame mame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mame mame merged commit 6570bd2 into ruby:master Apr 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants