Browse Source

Add condition to increase array size when last element is not nil

Veslo5 11 months ago
parent
commit
6eef1f2eb2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      src/Lua/LuaTable.cs

+ 2 - 2
src/Lua/LuaTable.cs

@@ -149,8 +149,8 @@ public sealed class LuaTable
         }
 
         var arrayIndex = index - 1;
-        
-        if (index > array.Length)
+
+        if (index > array.Length || array[^1].Type != LuaValueType.Nil)
         {
             EnsureArrayCapacity(array.Length + 1);
         }