From cc164baa15426345f6591729b86495d23c752474 Mon Sep 17 00:00:00 2001 From: Alasdair Date: Wed, 1 Nov 2023 01:19:23 +0000 Subject: [PATCH] Fix a bug with missing some polymorphic types in Jib monomorphization --- src/lib/jib_util.ml | 8 ++++---- test/c/issue362.expect | 1 + test/c/issue362.sail | 9 +++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 test/c/issue362.expect create mode 100644 test/c/issue362.sail diff --git a/src/lib/jib_util.ml b/src/lib/jib_util.ml index b39ec4c3a..44dd3f166 100644 --- a/src/lib/jib_util.ml +++ b/src/lib/jib_util.ml @@ -403,10 +403,10 @@ let rec ctyp_has pred ctyp = | CT_lint | CT_fint _ | CT_constant _ | CT_lbits | CT_fbits _ | CT_sbits _ | CT_float _ | CT_rounding_mode | CT_bit | CT_unit | CT_bool | CT_real | CT_string | CT_poly _ | CT_enum _ -> false - | CT_tup ctyps -> List.exists pred ctyps - | CT_ref ctyp | CT_vector ctyp | CT_fvector (_, ctyp) | CT_list ctyp -> pred ctyp - | CT_struct (id, fields) -> List.exists (fun (_, ctyp) -> pred ctyp) fields - | CT_variant (id, ctors) -> List.exists (fun (_, ctyp) -> pred ctyp) ctors + | CT_tup ctyps -> List.exists (ctyp_has pred) ctyps + | CT_ref ctyp | CT_vector ctyp | CT_fvector (_, ctyp) | CT_list ctyp -> ctyp_has pred ctyp + | CT_struct (id, fields) -> List.exists (fun (_, ctyp) -> ctyp_has pred ctyp) fields + | CT_variant (id, ctors) -> List.exists (fun (_, ctyp) -> ctyp_has pred ctyp) ctors let rec ctyp_equal ctyp1 ctyp2 = match (ctyp1, ctyp2) with diff --git a/test/c/issue362.expect b/test/c/issue362.expect new file mode 100644 index 000000000..9766475a4 --- /dev/null +++ b/test/c/issue362.expect @@ -0,0 +1 @@ +ok diff --git a/test/c/issue362.sail b/test/c/issue362.sail new file mode 100644 index 000000000..95b9c5adc --- /dev/null +++ b/test/c/issue362.sail @@ -0,0 +1,9 @@ +$include +$include + +union P ('a: Type) = { P1 : 'a } +union U = { U1 : P(unit) } +type T = result({'n, 'n > 0. (U, int('n))}, unit) + +val main : unit -> unit +function main () = let _ : T = Err(()) in print_endline("ok")