Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/frontend/cnf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ let rec make_term quant_basename t =

| TTrecord lbs ->
let lbs = List.map (fun (_, t) -> mk_term t) lbs in
E.mk_term (Sy.Op Sy.Record) lbs ty
E.mk_record lbs ty

| TTlet (binders, t2) ->
let binders =
Expand Down
14 changes: 11 additions & 3 deletions src/lib/frontend/d_cnf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -970,8 +970,16 @@ let rec mk_expr
E.mk_term sy [] ty

| B.Constructor _ ->
let ty = dty_to_ty term_ty in
E.mk_constr (Uid.of_dolmen tcst) [] ty
begin match dty_to_ty term_ty with
| Trecord _ as ty ->
E.mk_record [] ty
| Tadt _ as ty ->
E.mk_constr (Uid.of_dolmen tcst) [] ty
| Tunit ->
E.void
| ty ->
Fmt.failwith "unexpected type %a@." Ty.print ty
Comment on lines +978 to +981

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Collaborator Author

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 ;)

@Halbaroth Halbaroth Jun 18, 2024

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Collaborator Author

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.

end

| _ -> unsupported "Constant term %a" DE.Term.print term
end
Expand Down Expand Up @@ -1343,7 +1351,7 @@ let rec mk_expr
E.mk_term sy l ty
| Ty.Trecord _ ->
let l = List.map (fun t -> aux_mk_expr t) args in
E.mk_term (Sy.Op Sy.Record) l ty
E.mk_record l ty
| _ ->
Fmt.failwith
"Constructor error: %a does not belong to a record nor an\
Expand Down
7 changes: 5 additions & 2 deletions src/lib/reasoners/adt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,11 @@ module Shostak (X : ALIEN) = struct
if equal sel (embed sel_x) then X.term_embed t, ctx
else sel_x, ctx (* canonization OK *)
*)
| _ ->
assert false

| Sy.Op Sy.Constr _, _, Ty.Trecord _ ->
Fmt.failwith "unexpected record constructor %a@." E.print t

| _ -> assert false

let hash x =
abs @@ match x with
Expand Down
2 changes: 2 additions & 0 deletions src/lib/structures/expr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,8 @@ let mk_constr cons xs ty = mk_term (Sy.Op (Constr cons)) xs ty
let mk_tester cons t =
mk_builtin ~is_pos:true (Sy.IsConstr cons) [t]

let mk_record xs ty = mk_term (Sy.Op Record) xs ty

(** Substitutions *)

let is_skolem_cst v =
Expand Down
1 change: 1 addition & 0 deletions src/lib/structures/expr.mli
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ val mk_ite : t -> t -> t -> t

val mk_constr : Uid.t -> t list -> Ty.t -> t
val mk_tester : Uid.t -> t -> t
val mk_record : t list -> Ty.t -> t

(** Substitutions *)

Expand Down
Loading