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

Add parsing of sum type declarations #1088

Merged
merged 9 commits into from
Aug 3, 2023
Merged

Conversation

shonfeder
Copy link
Contributor

@shonfeder shonfeder commented Aug 2, 2023

Addresses the type declaration part of #1082.

This adds support for the sum type declaration syntax proposed in #1062.

The most interesting part of these changes is the addition of the IR constructs
to represent the declaration of sum types. This includes a specialized
variant of the row types allowing us to statically enforce that the rows of a
variant type cannot be open. See the discussion on #1062 for the motivation for
this design decision.

Note that we do not add a parsing rule to type for sum types. This reflects
the fact that sum types can only be referenced by their defined name: anonymous
sum types are not supported.

Note that this PR is into the sf/sum-type feature branch.

Shon Feder added 2 commits August 2, 2023 09:11
…d-ids

Require record fields to be simple identifiers
Copy link
Contributor

@thpani thpani left a comment

Choose a reason for hiding this comment

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

LGTM, just a few small remarks

quint/src/IRprinting.ts Show resolved Hide resolved
quint/src/graphics.ts Show resolved Hide resolved
quint/src/parsing/ToIrListener.ts Show resolved Hide resolved
Comment on lines +136 to +138
type T =
| A
| B(int)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also test type T = A | B(int)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call! I've added this :)

@shonfeder
Copy link
Contributor Author

Thanks for the review!

@shonfeder shonfeder merged commit 5843e65 into sf/sum-types Aug 3, 2023
15 checks passed
@shonfeder shonfeder deleted the sf/1082/syntax branch August 3, 2023 19:46
shonfeder pushed a commit that referenced this pull request Aug 3, 2023
* Add syntax for sum type declarations

* Add parser generator updates

* Adapt flattening and graphics for sum types

* Add unit test for sum type declaration parsing

* Update the super spec

Not sure why this updating. Tests succeed whether this file is updated
or not. But, well, it's up to date now :)

* Add test for IRPrinting
shonfeder pushed a commit that referenced this pull request Aug 4, 2023
* Add syntax for sum type declarations

* Add parser generator updates

* Adapt flattening and graphics for sum types

* Add unit test for sum type declaration parsing

* Update the super spec

Not sure why this updating. Tests succeed whether this file is updated
or not. But, well, it's up to date now :)

* Add test for IRPrinting
shonfeder pushed a commit that referenced this pull request Aug 4, 2023
* Add syntax for sum type declarations

* Add parser generator updates

* Adapt flattening and graphics for sum types

* Add unit test for sum type declaration parsing

* Update the super spec

Not sure why this updating. Tests succeed whether this file is updated
or not. But, well, it's up to date now :)

* Add test for IRPrinting
shonfeder pushed a commit that referenced this pull request Aug 5, 2023
These changes address the comments from
#1088

I had fixed all of these, but then merged the PR without pushing my
fixes.
shonfeder pushed a commit that referenced this pull request Aug 5, 2023
These changes address the comments from
#1088

I had fixed all of these, but then merged the PR without pushing my
fixes.
shonfeder pushed a commit that referenced this pull request Aug 7, 2023
These changes address the comments from
#1088

I had fixed all of these, but then merged the PR without pushing my
fixes.
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.

2 participants