Skip to content

Conversation

@sinsoku
Copy link
Contributor

@sinsoku sinsoku commented Dec 14, 2025

Previously, TypeProf would crash with "unknown type variable: Elem" when
a class constant like Array or Hash was passed to methods like all?:

[].all?(Array)  # => RuntimeError: unknown type variable: Elem

This happened because type parameters of Singleton types were not
registered in ty_env when resolving generic method signatures.

This commit fixes the issue by handling Type::Singleton in
get_instance_type, registering its type parameters with Source.new.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

Previously, TypeProf would crash with "unknown type variable: Elem" when
a class constant like `Array` or `Hash` was passed to methods like `all?`:

    [].all?(Array)  # => RuntimeError: unknown type variable: Elem

This happened because type parameters of Singleton types were not
registered in ty_env when resolving generic method signatures.

This commit fixes the issue by handling Type::Singleton in
get_instance_type, registering its type parameters with Source.new.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@sinsoku sinsoku force-pushed the fix-singleton-type-params branch from b4b3a5a to 3296d92 Compare December 14, 2025 06:27
Copy link
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.

Indeed... handling type parameters is difficult

@mame mame merged commit 5882778 into ruby:master Dec 23, 2025
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