Avoid OP_VARARGPREP for active lines

when building the table 'activelines' for a vararg function, this
first instruction does not make the first line active.
This commit is contained in:
Roberto Ierusalimschy
2021-11-10 15:07:14 -03:00
parent bfbff3703e
commit e8deac5a41
2 changed files with 51 additions and 1 deletions

View File

@@ -195,6 +195,49 @@ do -- testing line info/trace with large gaps in source
end
end
do -- testing active lines
local function checkactivelines (f, lines)
local t = debug.getinfo(f, "SL")
for _, l in pairs(lines) do
l = l + t.linedefined
assert(t.activelines[l])
t.activelines[l] = undef
end
assert(next(t.activelines) == nil) -- no extra lines
end
checkactivelines(function (...) -- vararg function
-- 1st line is empty
-- 2nd line is empty
-- 3th line is empty
local a = 20
-- 5th line is empty
local b = 30
-- 7th line is empty
end, {4, 6, 8})
checkactivelines(function (a)
-- 1st line is empty
-- 2nd line is empty
local a = 20
local b = 30
-- 5th line is empty
end, {3, 4, 6})
checkactivelines(function (...) end, {0})
checkactivelines(function (a, b)
end, {1})
for _, n in pairs{0, 1, 2, 10, 50, 100, 1000, 10000} do
checkactivelines(
load(string.format("%s return 1", string.rep("\n", n))),
{n + 1})
end
end
print'+'
-- invalid levels in [gs]etlocal