From bc57ed9df00261a6aead99291543cc610259f54e Mon Sep 17 00:00:00 2001 From: Brandon Dyck Date: Wed, 27 Sep 2023 22:38:32 -0600 Subject: [PATCH] Allow variable defs to use earlier names in list --- Interpreter.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Interpreter.cs b/Interpreter.cs index 0c82e0a..af71bbc 100644 --- a/Interpreter.cs +++ b/Interpreter.cs @@ -490,7 +490,9 @@ public class Interpreter : AST.IExprVisitor switch (binding) { case VarBinding(var pattern, var valueExpr): - var value = evaluate(env, valueExpr); + // By passing newEnv, we let the var definition refer to + // earlier bindings in the list. + var value = evaluate(newEnv, valueExpr); try { pattern.accept((value, newEnv), new PatternBinder());