Skip to content

Add tuple rest element support#50

Merged
yhk1038 merged 1 commit intomainfrom
feature/tuple-rest-element
Jan 23, 2026
Merged

Add tuple rest element support#50
yhk1038 merged 1 commit intomainfrom
feature/tuple-rest-element

Conversation

@yhk1038
Copy link
Contributor

@yhk1038 yhk1038 commented Jan 23, 2026

Summary

  • Add tuple rest element support ([Type, *Type[]] syntax)
  • Implement TupleRestElement IR node
  • Validate rest element position (must be at end, only one allowed)
  • RBS conversion fallback to union array (RBS doesn't support tuple rest)
  • LSP: tuple type completions and hover support

Example

# Basic tuple (existing)
[String, Integer]

# Tuple with rest element (new)
[String, *Integer[]]    # String + rest of Integers
[Header, *Row[]]        # Header + rest of Rows

Test plan

  • Parser unit tests
  • IR unit tests
  • E2E tests
  • LSP completion tests
  • All existing tests pass

Closes #44

Add support for tuple rest elements using the syntax `[Type, *Type[]]`.
This allows tuples with variable-length trailing elements.

Features:
- New `TupleRestElement` IR node for rest elements
- Parser support for `*Type[]` and `*Array<Type>` syntax
- Validation: rest must be at end, only one rest allowed
- RBS fallback: converts to union array (RBS doesn't support tuple rest)
- LSP: tuple type completions and hover support

Example:
```ruby
def get_values(): [String, *Integer[]]
  ["header", 1, 2, 3]
end
```
@yhk1038 yhk1038 merged commit aed4c6e into main Jan 23, 2026
10 checks passed
@yhk1038 yhk1038 deleted the feature/tuple-rest-element branch January 23, 2026 07:50
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.

[Enhancement] Tuple type support

1 participant