Skip to content

Conversation

@dak2
Copy link
Owner

@dak2 dak2 commented Jan 24, 2026

Support type variable resolution for block parameters

Changes

  • Add Type::Generic variant for Array[Integer], Hash[String, Integer]
  • Infer array literal element types: [1, 2, 3] -> Array[Integer]
  • Resolve Elem from Array, K/V from Hash in BlockParameterTypeBox
  • Fall back to base class in method registry for generic types

Examples

  [1, 2, 3].each { |x| x.upcase }
  # x is inferred as Integer, detects Integer#upcase error

Not yet supported

  • Hash literal element type inference
  • Nested generic types (e.g., Array[Array[Integer]])
  • Type variables in method return types
  • Range, Set, and other generic types

@dak2 dak2 changed the title support blocks Support type variable resolution for block parameters Jan 24, 2026
# Changes

- Add Type::Generic variant for Array[Integer], Hash[String, Integer]
- Infer array literal element types: [1, 2, 3] -> Array[Integer]
- Resolve Elem from Array, K/V from Hash in BlockParameterTypeBox
- Fall back to base class in method registry for generic types

# Examples

  [1, 2, 3].each { |x| x.upcase }
  # x is inferred as Integer, detects Integer#upcase error

# Not yet supported

- Hash literal element type inference
- Nested generic types (e.g., Array[Array[Integer]])
- Type variables in method return types
- Range, Set, and other generic types
@dak2 dak2 merged commit 36c0405 into main Jan 24, 2026
2 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