Skip to content

Support type variable resolution for block parameters#4

Merged
dak2 merged 1 commit into
mainfrom
support-blocks
Jan 24, 2026
Merged

Support type variable resolution for block parameters#4
dak2 merged 1 commit into
mainfrom
support-blocks

Conversation

@dak2

@dak2 dak2 commented Jan 24, 2026

Copy link
Copy Markdown
Owner

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
@dak2 dak2 deleted the support-blocks branch February 8, 2026 00:20
@dak2 dak2 mentioned this pull request Feb 8, 2026
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.

1 participant