diff --git a/Upsilon/BaseTypes/ScriptTable/ScriptTable.cs b/Upsilon/BaseTypes/ScriptTable/ScriptTable.cs index 8246a0a..ce8222b 100644 --- a/Upsilon/BaseTypes/ScriptTable/ScriptTable.cs +++ b/Upsilon/BaseTypes/ScriptTable/ScriptTable.cs @@ -27,13 +27,18 @@ namespace Upsilon.BaseTypes.ScriptTable { return o; } - diagnostics.LogError("Cannot find member 's' on Table", span); + diagnostics.LogError($"Cannot find member '{s}' on Table", span); return new ScriptNull(); } public void Set(Diagnostics diagnostics, TextSpan span, ScriptType index, ScriptType value) { var s = index.ToString(); + if (value.Type == Type.Nil) + { + EvaluationScope.Delete(s); + return; + } EvaluationScope.CreateLocal(new VariableSymbol(s, value.Type, false), value); } diff --git a/Upsilon/Evaluator/EvaluationScope.cs b/Upsilon/Evaluator/EvaluationScope.cs index ce4ddc9..4efcc69 100644 --- a/Upsilon/Evaluator/EvaluationScope.cs +++ b/Upsilon/Evaluator/EvaluationScope.cs @@ -59,6 +59,16 @@ namespace Upsilon.Evaluator Variables[symbol.Name] = value; } + public void Delete(VariableSymbol symbol) + { + Variables.Remove(symbol.Name); + } + + public void Delete(string name) + { + Variables.Remove(name); + } + public bool TryGet(VariableSymbol symbol, out ScriptType obj) {