mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add unit tests for Lua vector reading
This commit is contained in:
parent
a5263dc7ed
commit
ec16fb33d0
5 changed files with 197 additions and 20 deletions
|
@ -19,12 +19,14 @@ function meta:__newindex(name, value)
|
|||
return
|
||||
end
|
||||
local info = getinfo(2, "Sl")
|
||||
local desc = ("%s:%d"):format(info.short_src, info.currentline)
|
||||
local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name)
|
||||
if not warned[warn_key] and info.what ~= "main" and info.what ~= "C" then
|
||||
core.log("warning", ("Assignment to undeclared global %q inside a function at %s.")
|
||||
:format(name, desc))
|
||||
warned[warn_key] = true
|
||||
if info ~= nil then
|
||||
local desc = ("%s:%d"):format(info.short_src, info.currentline)
|
||||
local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name)
|
||||
if not warned[warn_key] and info.what ~= "main" and info.what ~= "C" then
|
||||
core.log("warning", ("Assignment to undeclared global %q inside a function at %s.")
|
||||
:format(name, desc))
|
||||
warned[warn_key] = true
|
||||
end
|
||||
end
|
||||
declared[name] = true
|
||||
end
|
||||
|
@ -35,6 +37,9 @@ function meta:__index(name)
|
|||
return
|
||||
end
|
||||
local info = getinfo(2, "Sl")
|
||||
if info == nil then
|
||||
return
|
||||
end
|
||||
local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name)
|
||||
if not warned[warn_key] and info.what ~= "C" then
|
||||
core.log("warning", ("Undeclared global variable %q accessed at %s:%s")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue