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

Wrong destructor for mutually recursive ADT #1009

Merged
merged 1 commit into from
Dec 12, 2023
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
9 changes: 5 additions & 4 deletions src/lib/frontend/d_cnf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1081,18 +1081,19 @@ let rec mk_expr

| B.Destructor { case; field; adt; _ }, [x] ->
begin match DT.definition adt with
| Some (Adt { cases; record; _ }) ->
| Some (Adt { cases; _ }) ->
begin match cases.(case).dstrs.(field) with
| Some { path; _ } ->
let name = get_basename path in
let ty = dty_to_ty term_ty in
let e = aux_mk_expr x in
let sy =
if record || Array.length cases = 1
then
match Cache.find_ty (DE.Ty.Const.hash adt) with
| Trecord _ ->
Sy.Op (Sy.Access (Hstring.make name))
else
| Tadt _ ->
Sy.destruct ~guarded:true name
| _ -> assert false
in
E.mk_term sy [e] ty
| _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/lib/structures/ty.mli
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ val t_adt :
?body: ((string * (string * t) list) list) option ->
string -> t list ->
t
(** Crearte and algebraic datatype. The body is a list of
(** Create an algebraic datatype. The body is a list of
constructors, where each constructor is associated with the list of
its destructors with their respective types. If [body] is none,
then no definition will be registered for this type. The second
Expand Down
Loading