From 964917d2f0194d3a2fbb869b2b41b6559c308861 Mon Sep 17 00:00:00 2001 From: John Date: Sun, 18 May 2025 11:47:13 -0400 Subject: [PATCH] cl-interpret: let now returns bool This makes debugging monumentally harder, but it's SO NEAT and instantly adds `if let`/`while let` and `let chaining` --- compiler/cl-interpret/src/interpret.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/cl-interpret/src/interpret.rs b/compiler/cl-interpret/src/interpret.rs index 67df8c8..61e2024 100644 --- a/compiler/cl-interpret/src/interpret.rs +++ b/compiler/cl-interpret/src/interpret.rs @@ -345,9 +345,12 @@ impl Interpret for Let { let Let { mutable: _, name, ty: _, init } = self; match init.as_ref().map(|i| i.interpret(env)).transpose()? { Some(value) => { - for (name, value) in pattern::substitution(name, value)? { - env.insert(*name, Some(value)); - } + if let Ok(sub) = pattern::substitution(name, value) { + for (name, value) in sub { + env.insert(*name, Some(value)); + } + return Ok(ConValue::Bool(true)); + }; } None => { for name in pattern::variables(name) { @@ -355,7 +358,7 @@ impl Interpret for Let { } } } - Ok(ConValue::Empty) + Ok(ConValue::Bool(false)) } }