New way to control preambular declaration

Validity of the preambular global declaration in controled together
with all declarations, when checking variable names.
This commit is contained in:
Roberto Ierusalimschy
2025-05-20 17:36:05 -03:00
parent 6d53701c7a
commit be05c44481
4 changed files with 45 additions and 15 deletions

View File

@@ -349,9 +349,11 @@ end, "crl")
function f(a,b)
global collectgarbage, assert, g, string
-- declare some globals to check that they don't interfere with 'getlocal'
global collectgarbage
collectgarbage()
local _, x = debug.getlocal(1, 1)
global assert, g, string
local _, y = debug.getlocal(1, 2)
assert(x == a and y == b)
assert(debug.setlocal(2, 3, "pera") == "AA".."AA")
@@ -387,7 +389,9 @@ function g (...)
f(AAAA,B)
assert(AAAA == "pera" and B == "manga")
do
global *
local B = 13
global<const> assert
local x,y = debug.getlocal(1,5)
assert(x == 'B' and y == 13)
end