ruby / ruby/rbs

Allow Type Variable constraints to be arbitrary types

Open
#1,471 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Ruby
Stars
2.2k
Forks
256
Avg merge
6d 17h
Merged PRs (30d)
37

Description

Currently, the RHS of [T < RHS] must be an interface, class or module, at least what RubyMine IDE identifies. Wynaut allow it to be anything? For the minumum, it can self-document when arg and return are the same constrained object/type: def []=: [E < Elem?] (index name_or_position, E) -> E

Originally posted in https://github.com/ruby/rbs/pull/1456#discussion_r1306579971; c.c. @sampersand

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the discussion from ruby/rbs#1456 and the existing handling of type-variable constraints for the [T < RHS] syntax. Define what accepting arbitrary RHS types means for the example def []=: [E < Elem?] (index name_or_position, E) -> E, then verify that the constraint is accepted and self-documents the shared argument and return type.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.