Browse Source

Fix: OP_VERARG

AnnulusGames 1 year ago
parent
commit
e2e874e445
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/Lua/Runtime/LuaVirtualMachine.cs

+ 3 - 1
src/Lua/Runtime/LuaVirtualMachine.cs

@@ -857,7 +857,9 @@ public static partial class LuaVirtualMachine
                         stack.EnsureCapacity(RA + count);
                         stack.EnsureCapacity(RA + count);
                         for (int i = 0; i < count; i++)
                         for (int i = 0; i < count; i++)
                         {
                         {
-                            stack.UnsafeGet(RA + i) = stack.UnsafeGet(frame.Base - (frame.VariableArgumentCount - i));
+                            stack.UnsafeGet(RA + i) = frame.VariableArgumentCount > i
+                                ? stack.UnsafeGet(frame.Base - (frame.VariableArgumentCount - i))
+                                : LuaValue.Nil;
                         }
                         }
                         stack.NotifyTop(RA + count);
                         stack.NotifyTop(RA + count);
                     }
                     }