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

@@ -364,7 +364,23 @@ do
print(X) -- Ok to use
Y = 1 -- ERROR
]], "assign to const variable 'Y'")
checkerr([[
global *;
Y = X -- Ok to use
global<const> *;
Y = 1 -- ERROR
]], "assign to const variable 'Y'")
global *
Y = 10
assert(_ENV.Y == 10)
global<const> *
local x = Y
global *
Y = x + Y
assert(_ENV.Y == 20)
end
print'OK'