diff --git a/cranelift/isle/isle/src/sema.rs b/cranelift/isle/isle/src/sema.rs index 61f19cd9d9..71491f84c6 100644 --- a/cranelift/isle/isle/src/sema.rs +++ b/cranelift/isle/isle/src/sema.rs @@ -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. diff --git a/cranelift/isle/isle_examples/let.isle b/cranelift/isle/isle_examples/let.isle new file mode 100644 index 0000000000..c43d1ec668 --- /dev/null +++ b/cranelift/isle/isle_examples/let.isle @@ -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)))