summaryrefslogtreecommitdiff
path: root/src/specialize.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/specialize.ml')
-rw-r--r--src/specialize.ml24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/specialize.ml b/src/specialize.ml
index eaef1231..646b92f7 100644
--- a/src/specialize.ml
+++ b/src/specialize.ml
@@ -351,8 +351,9 @@ let specialize_id_valspec spec instantiations id ast =
(* When we specialize a function definition we also need to specialize
all the types that appear as annotations within the function
- body. *)
-let specialize_annotations instantiation =
+ body. Also remove any type-annotation from the fundef itself,
+ because at this point we have that as a separate valspec.*)
+let specialize_annotations instantiation fdef =
let open Type_check in
let rw_pat = {
id_pat_alg with
@@ -364,11 +365,20 @@ let specialize_annotations instantiation =
lEXP_cast = (fun (typ, lexp) -> LEXP_cast (subst_unifiers instantiation typ, lexp));
pat_alg = rw_pat
} in
- rewrite_fun {
- rewriters_base with
- rewrite_exp = (fun _ -> fold_exp rw_exp);
- rewrite_pat = (fun _ -> fold_pat rw_pat)
- }
+ let fdef =
+ rewrite_fun {
+ rewriters_base with
+ rewrite_exp = (fun _ -> fold_exp rw_exp);
+ rewrite_pat = (fun _ -> fold_pat rw_pat)
+ } fdef
+ in
+ match fdef with
+ | FD_aux (FD_function (rec_opt, _, eff_opt, funcls), annot) ->
+ FD_aux (FD_function (rec_opt,
+ Typ_annot_opt_aux (Typ_annot_opt_none, Parse_ast.Unknown),
+ eff_opt,
+ funcls),
+ annot)
let specialize_id_fundef instantiations id ast =
match split_defs (is_fundef id) ast with