Browse Source

Change: add NaN check

AnnulusGames 1 year ago
parent
commit
f8ad639f6e
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Lua/LuaTable.cs

+ 5 - 0
src/Lua/LuaTable.cs

@@ -42,6 +42,11 @@ public sealed class LuaTable
         }
         set
         {
+            if (key.Type is LuaValueType.Number && double.IsNaN(key.Read<double>()))
+            {
+                throw new ArgumentException("table index is NaN");
+            }
+
             if (TryGetInteger(key, out var index))
             {
                 if (0 < index && index <= Math.Max(array.Length * 2, 8))