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: Exact Table Types #624

Closed
wants to merge 4 commits into from
Closed

Conversation

aatxe
Copy link
Collaborator

@aatxe aatxe commented Aug 4, 2022

@andyfriesen andyfriesen added the rfc Language change proposal label Aug 4, 2022
Copy link
Contributor

@JohnnyMorganz JohnnyMorganz left a comment

Choose a reason for hiding this comment

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

From first read, looks like this solves #455, if I'm not mistaken. If so, major +1.
Double +1 for making exact the default as well.

Comment on lines +217 to +223
mitigate problems. Since Luau currently only has sealed, inexact table types we can start by adding
the syntax for explicit inexact tables (e.g. `{x: number, y: number, ...}`) and implement a warning
that explains the default behavior will change in the future and to change it to the explicit
inexact syntax if the programmer would like to keep the current behavior. At a later date, we can
enable exact-by-default, but should provide an explicit suggestion in the error message to tell the
programmer that if they _intended_ to allow tables with additional properties, they can change the
signature of the function to include the `...`.
Copy link
Contributor

@JohnnyMorganz JohnnyMorganz Aug 4, 2022

Choose a reason for hiding this comment

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

Maybe the discussion about how inexact tables will work should be more prominent than just a section inside "Drawbacks", or is this intended to go in a different RFC? It feels like an important point, especially migration

e.g., Personally, I have no particular opinion, but were alternatives in syntax considered (such as TypeScript's interface { })

Copy link
Collaborator Author

@aatxe aatxe Aug 4, 2022

Choose a reason for hiding this comment

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

There is (admittedly brief) mention in the design section about the syntax of inexact tables. Is there something you're concerned isn't discussed? I can, at minimum, say explicitly that the behavior of inexact tables defined using the proposed inexact syntax would be the same as the current behavior (i.e. they support the width subtyping already accepted and implemented in #38.)

Copy link
Contributor

@JohnnyMorganz JohnnyMorganz Aug 5, 2022

Choose a reason for hiding this comment

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

Ah yeah, I see it now - I must have missed it earlier.

No particular issue for me, just a note that it is very likely to get comments down the road from users about "why was XYZ not chosen", especially for syntax - but this is more of a nitpicking comment

@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: I don't fully know if this is still on the table given where we are at with other advances in the type system... it does feel like this may cover a significant gap between our users' perception of what types do, and what they actually do right now.

@zeux zeux closed this Oct 30, 2023
@aatxe
Copy link
Collaborator Author

aatxe commented Oct 30, 2023

I think this is still on the table. I'm less optimistic now than I was at the time about the syntactic migration (to exact by default), but I do think there's considerable value in that. Even if we don't, it seems like having support for table types without width subtyping is broadly desirable and something we want to support.

Additionally, the ongoing work on the new type inference engine is already helping to clear up the muddied waters with unsealed tables since we have put in the work to truly make them an inference detail and not directly manifest to users. So, we're essentially freeing up complexity budget around table types right now.

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.

4 participants