Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method overload narrowing #1875

Open
3 tasks
ParadoxV5 opened this issue Jun 7, 2024 · 0 comments
Open
3 tasks

Method overload narrowing #1875

ParadoxV5 opened this issue Jun 7, 2024 · 0 comments

Comments

@ParadoxV5
Copy link
Contributor

ParadoxV5 commented Jun 7, 2024

I request a notation for method overload narrowing, such that subtype args narrow supertype args.
The intent is so the return type of supertype overloads not longer need to explicitly include those of narrower overloads.

E.g., TrueClass#& example from prior brief discussion on Discord:

def &: (false? rhs) -> false
     | (untyped rhs) -> true

Contrast with our current compromise:

rbs/core/true_class.rbs

Lines 28 to 29 in 45b34bd

def &: (false | nil) -> false
| (untyped obj) -> bool

This new solution enables us to type the result for truthy args without needing a “difference type” type truthy = top - false?.
In fact, this is possibly the only practical use case for “difference types”.

I’ve considered moving this focus to Steep but decided that the entire RBS ecosystem could use this.
For example, #1874 (comment) finally encouraged me to formally file this issue.

Though it is backward-incompatible to change the semantics of | set by yore, we can instead introduce an new, alternative syntax, such as the tokens:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant