Constraints on variables
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
It seems that currently the grammar only supports type constraints in the case of module declarations. It would be very useful to be able to constrain type variables, e.g. to require a particular interface.
For example:
interface _Comparable
def <=>: (untyped other) -> Integer | nil
end
class Heap[Elem : _Comparable]
def add: (Elem) -> void
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the module declaration section linked in docs/syntax.md and the issue’s RBS example. Determine the syntax and behavior needed for constrained type variables, then ensure the Heap[Elem : _Comparable] example is accepted and its constraint is enforced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100