Added record update field punning

This commit is contained in:
Brandon Dyck 2023-07-11 13:12:02 -06:00
parent c12a0cffc8
commit fc710d038f

View File

@ -508,10 +508,10 @@ public class Interpreter : AST.IExprVisitor<Env, object>
throw new RuntimeError(tok, "Record updates must be to unique fields."); throw new RuntimeError(tok, "Record updates must be to unique fields.");
} }
updateLabels.Add(label); updateLabels.Add(label);
if (update.Value == null) throw new NotImplementedException(); var updateValue = update.Value == null ? env[update.Name] : evaluate(env, update.Value);
try try
{ {
baseRec = baseRec.Update(label, evaluate(env, update.Value)); baseRec = baseRec.Update(label, updateValue);
} }
catch catch
{ {