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

RFC for shared self types #863

Closed
wants to merge 6 commits into from

Conversation

asajeffrey
Copy link
Collaborator

@asajeffrey asajeffrey commented Mar 15, 2023

An RFC about the treatment of self parameters in methods declared with function t:m(). Currently every method gets a separate type for self, but with this proposal they'd get the same type. This produces better type errors, and can drastically reduce the memory footprint of types.

Rendered: https://github.com/asajeffrey/luau/blob/rfc-shared-self-types/rfcs/shared-self-types.md

@asajeffrey asajeffrey added the rfc Language change proposal label Mar 15, 2023
type t<As> = U
```

which defines, when `t` has type `T`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be precise, you mean if there is already a local named t in the scope that has unsealed type T?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be unsealed (though it's not much use if it's sealed).

@vegorov-rbx
Copy link
Collaborator

If the user decides to add an explicit type annotation type t<As> = U, is it placed somewhere at the beginning (before method declarations), at the end (like developers often do right now with type t = typeof(...)) or is it independent of visit order?

Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
@asajeffrey
Copy link
Collaborator Author

@zeux
Copy link
Collaborator

zeux commented Oct 30, 2023

This PR is closed as part of RFC migration; please see #1074 (comment) for context.

Additional notes: This represents a significant user need, so this feels like something we need to finish specifying and implement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rfc Language change proposal
Development

Successfully merging this pull request may close these issues.

None yet

3 participants