[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: minor bug in error message of table.remove
- From: Alexander Chernoskutov <alecherov@...>
- Date: Wed, 7 Sep 2022 19:59:40 +0500
Hi!
I found a minor bug in error message of table.remove().
If you do
> a = {1}
> table.remove(a, 10)
you get
> stdin:1: bad argument #1 to 'remove' (position out of bounds)
But 'bad argument' is actually #2, not #1.
A possible fix
Commit: 997f11f54322883c3181225f29d101a597f31730
--- a/ltablib.c
+++ b/ltablib.c
@@ -93,7 +93,7 @@ static int tremove (lua_State *L) {
lua_Integer pos = luaL_optinteger(L, 2, size);
if (pos != size) /* validate 'pos' if given */
/* check whether 'pos' is in [1, size + 1] */
- luaL_argcheck(L, (lua_Unsigned)pos - 1u <= (lua_Unsigned)size, 1,
+ luaL_argcheck(L, (lua_Unsigned)pos - 1u <= (lua_Unsigned)size, 2,
"position out of bounds");
lua_geti(L, 1, pos); /* result = t[pos] */
for ( ; pos < size; pos++) {
--
--
With regards, Alex Ch