Debug information about extra arguments from __call

'debug.getinfo' can return number of extra arguments added to a call by
a chain of __call metavalues. That information is being used to improve
error messages about errors in these extra arguments.
This commit is contained in:
Roberto Ierusalimschy
2024-11-19 14:09:18 -03:00
parent b117bdb344
commit 50c7c915ee
9 changed files with 83 additions and 12 deletions

View File

@@ -4850,6 +4850,7 @@ typedef struct lua_Debug {
unsigned char nups; /* (u) number of upvalues */
unsigned char nparams; /* (u) number of parameters */
char isvararg; /* (u) */
unsigned char extraargs; /* (t) number of extra arguments */
char istailcall; /* (t) */
int ftransfer; /* (r) index of first value transferred */
int ntransfer; /* (r) number of transferred values */
@@ -4938,6 +4939,14 @@ true if this function invocation was called by a tail call.
In this case, the caller of this level is not in the stack.
}
@item{@id{extraargs}|
The number of extra arguments added by the call
to functions called through @idx{__call} metamethods.
(Each @idx{__call} metavalue adds a single extra argument,
the object being called,
but there may be a chain of @idx{__call} metavalues.)
}
@item{@id{nups}|
the number of upvalues of the function.
}
@@ -5045,7 +5054,7 @@ fills in the fields @id{source}, @id{short_src},
@id{linedefined}, @id{lastlinedefined}, and @id{what};
}
@item{@Char{t}| fills in the field @id{istailcall};
@item{@Char{t}| fills in the fields @id{istailcall} and @id{extraargs};
}
@item{@Char{u}| fills in the fields
@@ -7993,7 +8002,7 @@ returns @fail plus the position of the first invalid byte.
@LibEntry{utf8.offset (s, n [, i])|
Returns the the position of the @id{n}-th character of @id{s}
Returns the position of the @id{n}-th character of @id{s}
(counting from byte position @id{i}) as two integers:
The index (in bytes) where its encoding starts and the
index (in bytes) where it ends.