Fix let variable typing rules

This commit is contained in:
Nick Fitzgerald
2021-09-28 12:03:11 -07:00
committed by Chris Fallin
parent 972dc00a92
commit 922a3886d5
2 changed files with 22 additions and 1 deletions

View File

@@ -1251,7 +1251,7 @@ impl TermEnv {
};
// Evaluate the variable's value.
let val = Box::new(match self.translate_expr(tyenv, &def.val, ty, bindings) {
let val = Box::new(match self.translate_expr(tyenv, &def.val, tid, bindings) {
Some(e) => e,
None => {
// Keep going for more errors.

View File

@@ -0,0 +1,21 @@
(type u32 (primitive u32))
(type A (enum (Add (x u32) (y u32)) (Sub (x u32) (y u32))))
(type B (enum (B (z u32))))
(decl Sub (u32 u32) u32)
(extern constructor Sub sub)
(decl Add (u32 u32) u32)
(extern constructor Add add)
(decl Lower (A) B)
(rule
(Lower (A.Add x y))
(let ((z u32 (Add x y)))
(B.B z)))
(rule
(Lower (A.Sub x y))
(let ((z u32 (Sub x y)))
(B.B z)))