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

Support {} for empty record literals and types. #5658

Merged
merged 4 commits into from Sep 13, 2022

Conversation

cristianoc
Copy link
Collaborator

@cristianoc cristianoc commented Sep 12, 2022

Example:

type allOptRec = {n?: int, s?:string}

let construct = (b) => b ? {n:0} : {}

// let z = {}
// Error: Empty record literal {} should be type annotated or used in a record context.

type emptyrec = {}

let er : emptyrec = {}

@cristianoc cristianoc mentioned this pull request Sep 12, 2022
14 tasks
@cristianoc
Copy link
Collaborator Author

Uses: rescript-lang/syntax#632

@cristianoc
Copy link
Collaborator Author

cristianoc commented Sep 12, 2022

Note: only handles expressions so far, not patterns.
Not clear there is missing expressivity with patterns. As long as one optional field exists, one can match on it being None.

No need for {} in patterns as it's the same as _.

@cristianoc cristianoc changed the title Test: support {} for empty records. Support {} for empty record literals and types. Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant