Skip to content

Commit

Permalink
Coq: be more careful when type variables couldn't be merged
Browse files Browse the repository at this point in the history
  • Loading branch information
bacam committed Jun 6, 2024
1 parent a06c2b9 commit 6cfc721
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sail_coq_backend/pretty_print_coq.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,10 @@ let doc_exp, doc_let =
);
underscore
| Some (Nexp_aux (Nexp_var _, _)), Some (Nexp_aux (Nexp_constant c, _)) -> string (Big_int.to_string c)
(* If an integer argument is the same as a type variable, but we couldn't merge them, then use the type variable to ensure that the result type won't be the wrong one. *)
| Some (Nexp_aux (Nexp_var v, _)), _
when KidSet.mem v ctxt.bound_nvars && not (KBindings.mem v ctxt.kid_id_renames) ->
doc_var ctxt v
| _ -> construct_dep_pairs ctxt inst_env want_parens arg typ_from_fn
in
let epp =
Expand Down
10 changes: 10 additions & 0 deletions test/coq/pass/unmergeablefn.sail
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
default Order dec
$include <prelude.sail>

/* Putting the integer for 'n inside a pair prevents the Coq backend from
merging the type variable and the argument, so it has to be careful about
the value passed to sail_zeros. */

val f : forall 'n, 'n > 0. (bool, (int('n), bool)) -> bits('n)

function f(b, p) = match p { (n, b2) => sail_zeros(n) }

0 comments on commit 6cfc721

Please sign in to comment.