diff --git a/src/MoonSharp.Interpreter/DataTypes/Table.cs b/src/MoonSharp.Interpreter/DataTypes/Table.cs index c4a4bec4..ea4299f5 100644 --- a/src/MoonSharp.Interpreter/DataTypes/Table.cs +++ b/src/MoonSharp.Interpreter/DataTypes/Table.cs @@ -161,6 +161,12 @@ public void Append(DynValue value) private void PerformTableSet(LinkedListIndex listIndex, T key, DynValue keyDynValue, DynValue value, bool isNumber, int appendKey) { + if (value == null) + { + PerformTableRemove(listIndex, key, isNumber); + return; + } + TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value)); // If this is an insert, we can invalidate all iterators and collect dead keys diff --git a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs index c4a4bec4..ea4299f5 100644 --- a/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs +++ b/src/MoonSharp.Interpreter/_Projects/MoonSharp.Interpreter.netcore/src/DataTypes/Table.cs @@ -161,6 +161,12 @@ public void Append(DynValue value) private void PerformTableSet(LinkedListIndex listIndex, T key, DynValue keyDynValue, DynValue value, bool isNumber, int appendKey) { + if (value == null) + { + PerformTableRemove(listIndex, key, isNumber); + return; + } + TablePair prev = listIndex.Set(key, new TablePair(keyDynValue, value)); // If this is an insert, we can invalidate all iterators and collect dead keys