Skip to content

Commit

Permalink
Mono: correct some type annotations in constant propagation
Browse files Browse the repository at this point in the history
Including fixing nexp substitution in terms so that it doesn't remove
attributes.
  • Loading branch information
bacam committed Dec 7, 2023
1 parent 1ccaff3 commit eb350e8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/lib/constant_propagation.ml
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,12 @@ let const_props target ast =
)
| E_let (lb, e2) -> begin
match lb with
| LB_aux (LB_val (p, e), annot) -> (
| LB_aux (LB_val (p, e), lb_annot) -> (
let e', assigns = const_prop_exp substs assigns e in
let substs' = remove_bound substs p in
let plain () =
let e2', assigns = const_prop_exp substs' assigns e2 in
re (E_let (LB_aux (LB_val (p, e'), annot), e2')) assigns
re (E_let (LB_aux (LB_val (p, e'), lb_annot), e2')) assigns
in
match can_match l e' [Pat_aux (Pat_exp (p, e2), (Unknown, empty_tannot))] substs assigns with
| None -> plain ()
Expand All @@ -542,10 +542,11 @@ let const_props target ast =
let tail_exp, tail_assigns = const_prop_exp substs'' assigns e'' in
( List.fold_left
(fun (E_aux (_, t_annot) as t_exp) (id, bind_exp) ->
let p_tannot = mk_tannot (env_of_annot (l, annot)) (typ_of bind_exp) in
E_aux
( E_let
( LB_aux
( LB_val (P_aux (P_id id, (Generated l, empty_tannot)), bind_exp),
( LB_val (P_aux (P_id id, (Generated l, p_tannot)), bind_exp),
(Generated l, empty_tannot)
),
t_exp
Expand Down
4 changes: 2 additions & 2 deletions src/lib/spec_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ let nexp_subst_fns substs =
let s_typschm tsh = tsh in*)
let s_tannot tannot =
match Type_check.destruct_tannot tannot with
| None -> Type_check.empty_tannot
| Some (env, t) -> Type_check.mk_tannot env (s_t t)
| None -> tannot
| Some (_env, t) -> Type_check.replace_typ (s_t t) tannot
(* TODO: what about env? *)
in
let rec s_pat (P_aux (p, (l, annot))) =
Expand Down

0 comments on commit eb350e8

Please sign in to comment.