-
Notifications
You must be signed in to change notification settings - Fork 33
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
Simple ADTs with a single constructor are records #1146
Conversation
This PR fixes a bug in `D_cnf` that have been exposed by OCamlPro#1130. Before merging `Enum` into `ADT` the situation was as follows: - simple ADT with several constructors and with at least one payload was sent to the `Adt` theory - simple ADT with several constructors but no payload was sent to `Enum` theory - simple ADT with a single constructor was sent to the `Record` theory. The last corner case includes a corner corner case: An ADT with a single constructor without payload (so basically the unit type with an extra step...) The `D_cnf` included a bug. It produced single constructors without payload of type ADT instead of type record but the check done in `is_mine_symb` prevented from sending it to `Adt`. As I removed this check, we got an assert on the following input: ```smt2 (set-logic ALL) (declare-datatype t ((Record))) (define-fun a () t Record) (check-sat) ``` After this patch, the situation is as follows: - simple ADT with several constructors is sent to the `Adt` theory - simple ADT with only one constructor is sent to the `Record` theory - mutually recursive ADT whose all the types are record is sent to the `Record` theory
| Tunit -> | ||
E.void | ||
| ty -> | ||
Fmt.failwith "unexpected type %a@." Ty.print ty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test that shows that Tunit is used? And that we crash if we don't match it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2000 regressions on ae-format
without this case, so yes, we have tests :)
Actually the builtin unit
type of Dolmen
is an ADT but a distinct builtin type Tunit
in Alt-Ergo. It's a corner corner corner case...
I tested this PR on ae-format
and now there is no regression anymore ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a unit test to catch unit (sic) case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, I removed the Ty.Tunit
type of AE in #1148, so this corner case disappears.
* Simple ADTs with a single constructor are records This PR fixes a bug in `D_cnf` that have been exposed by OCamlPro#1130. Before merging `Enum` into `ADT` the situation was as follows: - simple ADT with several constructors and with at least one payload was sent to the `Adt` theory - simple ADT with several constructors but no payload was sent to `Enum` theory - simple ADT with a single constructor was sent to the `Record` theory. The last corner case includes a corner corner case: An ADT with a single constructor without payload (so basically the unit type with an extra step...) The `D_cnf` included a bug. It produced single constructors without payload of type ADT instead of type record but the check done in `is_mine_symb` prevented from sending it to `Adt`. As I removed this check, we got an assert on the following input: ```smt2 (set-logic ALL) (declare-datatype t ((Record))) (define-fun a () t Record) (check-sat) ``` After this patch, the situation is as follows: - simple ADT with several constructors is sent to the `Adt` theory - simple ADT with only one constructor is sent to the `Record` theory - mutually recursive ADT whose all the types are record is sent to the `Record` theory
This PR fixes a bug in
D_cnf
that have been exposed by #1130. Before mergingEnum
intoADT
the situation was as follows:Adt
theoryEnum
theoryRecord
theory.The last corner case includes a corner corner case: an ADT with a single constructor without payload (so basically the unit type with an extra step...)
The
D_cnf
included a bug. It produced single constructors without payload of type ADT instead of type record but the check done inis_mine_symb
prevented from sending it toAdt
. As I removed this check, we got an assert on the following input:After this patch, the situation is as follows:
Adt
theoryRecord
theoryRecord
theory