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

[DMS-12] Variant types #16

Merged
merged 6 commits into from
May 20, 2024
Merged

[DMS-12] Variant types #16

merged 6 commits into from
May 20, 2024

Conversation

int-index
Copy link
Member

New test case: test/viper/variants.mo

let {it = (e_ds, e_stmts);_} = stmt local_ctxt e in
let the = (p_ds @ e_ds, p_stmts @ e_stmts) in
let els = switch_stmts ctxt at scrut cs in
[], [!!(IfS(conjoin conds at, !!the, !!els))]
Copy link

Choose a reason for hiding this comment

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

Suggestion: do cojoin conds in pat_match

Copy link

Choose a reason for hiding this comment

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

It makes code a bit more general and maybe a bit simpler. But I am fine with current code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's better to return a list of conditions from pat_match so that it's possible to check for irrefutable patterns by conds == []

Copy link

@GoPavel GoPavel left a comment

Choose a reason for hiding this comment

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

Other things look good to me

@@ -11,10 +11,13 @@ type prog = (item list, info) Source.annotated_phrase
and item = (item', info) Source.annotated_phrase
and item' =
(* | import path *)
| AdtI of string * string list * adt_con list
Copy link

Choose a reason for hiding this comment

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

Suggested change
| AdtI of string * string list * adt_con list
| AdtI of id * id list * adt_con list

I think it should be string with location of original ids from the source code.
I know that we are not checking this in tests and even manually, but I think it's a good thing to keep common style of definitions at least in types. In the translation you can put Source.no_region as a stab value.

| FieldI of id * typ
| MethodI of id * par list * par list * exp list * exp list * seqn option
| InvariantI of string * exp

and adt_con = { con_name : string; con_fields : typ list }
Copy link

Choose a reason for hiding this comment

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

Suggested change
and adt_con = { con_name : string; con_fields : typ list }
and adt_con = { con_name : id; con_fields : typ list }

+1 for the previous thread

@@ -98,4 +101,5 @@ and typ' =
| RefT
| ArrayT
| TupleT
| ConT of string * typ list
Copy link

Choose a reason for hiding this comment

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

Suggested change
| ConT of string * typ list
| ConT of id * typ list

+1 for the previous thread

@int-index int-index merged commit 8dbcc6f into master May 20, 2024
1 of 4 checks passed
@delete-merged-branch delete-merged-branch bot deleted the motoko-san/variants branch May 20, 2024 15:12
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