Skip to content

Commit

Permalink
Merge pull request #35 from ToposInstitute/nested-let
Browse files Browse the repository at this point in the history
Fix issue with nested let bindings
  • Loading branch information
solomon-b authored Jul 3, 2023
2 parents ae4d001 + a605c1c commit b0fd023
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/refiner/rules/Var.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ let let_bind ?(name = `Anon) (tm : Syn.tac) (f : Var.tac -> Chk.tac) =
Chk.rule @@ fun rtp ->
let (vtp, etm) = Syn.run tm in
let vtm = Eff.eval etm in
let body = Chk.run (Var.concrete ~name vtp vtm f) rtp in
let body =
Var.concrete ~name vtp vtm @@ fun v ->
Chk.run (f v) rtp
in
Let (name, etm, body)

let negative (cell : Cell.neg) =
Expand Down
1 change: 1 addition & 0 deletions test/let/polytt-lib
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "format": "1.0.0" }
9 changes: 9 additions & 0 deletions test/let/test-let.poly
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def add : ℕ → ℕ → ℕ :=
λ m n → elim (λ _ → ℕ) n (λ _ n → succ n) m

def nested-let : ℕ :=
let x := 4 in
let y := 5 in
add x y

#normalize nested-let
3 changes: 3 additions & 0 deletions test/test.expected
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Normal Form: λ P Q → λ ~> FIXME λ pf⁺ → (fst (snd pf⁺ (fst pf⁺)) ,
Normal Form: (12 , λ <7> → (succ (succ <7>) , (3 , <7>)))
Normal Form: λ P Q → λ ~> FIXME λ pq⁺ → ((fst pq⁺ , λ _ → snd pq⁺) , λ <3> → (fst <3> , snd <3>)) FIXME
Normal Form: λ S T A B → #{ .get, .set } → { .get = S → A, .set = S → B → T } _
--------------------[test-let.poly]--------------------

Normal Form: 9
--------------------[a.poly]--------------------

--------------------[b.poly]--------------------
Expand Down

0 comments on commit b0fd023

Please sign in to comment.