Fix let variable typing rules
This commit is contained in:
committed by
Chris Fallin
parent
972dc00a92
commit
922a3886d5
@@ -1251,7 +1251,7 @@ impl TermEnv {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Evaluate the variable's value.
|
// 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,
|
Some(e) => e,
|
||||||
None => {
|
None => {
|
||||||
// Keep going for more errors.
|
// Keep going for more errors.
|
||||||
|
|||||||
21
cranelift/isle/isle_examples/let.isle
Normal file
21
cranelift/isle/isle_examples/let.isle
Normal 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)))
|
||||||
Reference in New Issue
Block a user