Allow variable defs to use earlier names in list

This commit is contained in:
Brandon Dyck 2023-09-27 22:38:32 -06:00
parent 352fa9616e
commit bc57ed9df0

View File

@ -490,7 +490,9 @@ public class Interpreter : AST.IExprVisitor<Env, object>
switch (binding) switch (binding)
{ {
case VarBinding(var pattern, var valueExpr): 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 try
{ {
pattern.accept((value, newEnv), new PatternBinder()); pattern.accept((value, newEnv), new PatternBinder());