Skip to content

Commit

Permalink
Fix a bug with missing some polymorphic types in Jib monomorphization
Browse files Browse the repository at this point in the history
  • Loading branch information
Alasdair committed Nov 1, 2023
1 parent 83c2900 commit cc164ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/jib_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/c/issue362.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ok
9 changes: 9 additions & 0 deletions test/c/issue362.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$include <result.sail>
$include <string.sail>

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

0 comments on commit cc164ba

Please sign in to comment.