diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-11-19 14:09:18 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-11-19 14:09:18 -0300 |
| commit | 50c7c915ee2fa239043d5456237f5145d064089b (patch) | |
| tree | 386e17e4baa154bb60dc54c1a00c751e3adedde9 /testes/calls.lua | |
| parent | b117bdb3448778d9e7f9a0302791e8ac3bb97ddd (diff) | |
| download | lua-50c7c915ee2fa239043d5456237f5145d064089b.tar.gz lua-50c7c915ee2fa239043d5456237f5145d064089b.tar.bz2 lua-50c7c915ee2fa239043d5456237f5145d064089b.zip | |
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.
Diffstat (limited to 'testes/calls.lua')
| -rw-r--r-- | testes/calls.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/testes/calls.lua b/testes/calls.lua index 12312d60..31028215 100644 --- a/testes/calls.lua +++ b/testes/calls.lua | |||
| @@ -204,6 +204,17 @@ do print"testing chains of '__call'" | |||
| 204 | assert(Res[i][1] == i) | 204 | assert(Res[i][1] == i) |
| 205 | end | 205 | end |
| 206 | assert(Res[N + 1] == "a" and Res[N + 2] == "b" and Res[N + 3] == "c") | 206 | assert(Res[N + 1] == "a" and Res[N + 2] == "b" and Res[N + 3] == "c") |
| 207 | |||
| 208 | local function u (...) | ||
| 209 | local n = debug.getinfo(1, 't').extraargs | ||
| 210 | assert(select("#", ...) == n) | ||
| 211 | return n | ||
| 212 | end | ||
| 213 | |||
| 214 | for i = 0, N do | ||
| 215 | assert(u() == i) | ||
| 216 | u = setmetatable({}, {__call = u}) | ||
| 217 | end | ||
| 207 | end | 218 | end |
| 208 | 219 | ||
| 209 | 220 | ||
