Skip to content

Commit

Permalink
normalizer: fix backwards environment!
Browse files Browse the repository at this point in the history
Fixes #2849
  • Loading branch information
mtzguido committed Mar 13, 2023
1 parent 9594e8f commit a132a34
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/typechecker/FStar.TypeChecker.Normalize.fst
Original file line number Diff line number Diff line change
Expand Up @@ -1628,8 +1628,11 @@ let rec norm : cfg -> env -> stack -> term -> term =
let rec_env = (None, Clos(env, fix_f_i, memo, true))::rec_env in
rec_env, memo::memos, i + 1) (snd lbs) (env, [], 0) in
let _ = List.map2 (fun lb memo -> memo := Some (rec_env, lb.lbdef)) (snd lbs) memos in //tying the knot
let body_env = List.fold_right (fun lb env -> (None, Clos(rec_env, lb.lbdef, BU.mk_ref None, false))::env)
(snd lbs) env in
// NB: fold_left, since the binding structure of lbs is that righmost is closer, while in the env leftmost
// is closer. In other words, the last element of lbs is index 0 for body, hence needs to be pushed last.
let body_env = List.fold_left (fun env lb -> (None, Clos(rec_env, lb.lbdef, BU.mk_ref None, false))::env)
env (snd lbs) in
log cfg (fun () -> BU.print1 "reducing with knot %s\n" "");
norm cfg body_env stack body

| Tm_meta (head, m) ->
Expand Down

0 comments on commit a132a34

Please sign in to comment.