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.");
}
updateLabels.Add(label);
if (update.Value == null) throw new NotImplementedException();
var updateValue = update.Value == null ? env[update.Name] : evaluate(env, update.Value);
try
{
baseRec = baseRec.Update(label, evaluate(env, update.Value));
baseRec = baseRec.Update(label, updateValue);
}
catch
{