aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/common')
-rw-r--r--builtin/common/strict.lua14
1 files changed, 4 insertions, 10 deletions
diff --git a/builtin/common/strict.lua b/builtin/common/strict.lua
index c7b86461f..05ceadf7a 100644
--- a/builtin/common/strict.lua
+++ b/builtin/common/strict.lua
@@ -9,11 +9,6 @@ function core.global_exists(name)
end
-local function warn(message)
- print(os.date("%H:%M:%S: WARNING: ")..message)
-end
-
-
local meta = {}
local declared = {}
-- Key is source file, line, and variable name; seperated by NULs
@@ -27,7 +22,7 @@ function meta:__newindex(name, value)
info.currentline, name)
if not warned[warn_key] and info.what ~= "main" and
info.what ~= "C" then
- warn(("Assignment to undeclared "..
+ core.log("warning", ("Assignment to undeclared "..
"global %q inside a function at %s.")
:format(name, desc))
warned[warn_key] = true
@@ -35,9 +30,8 @@ function meta:__newindex(name, value)
declared[name] = true
end
-- Ignore mod namespaces
- if WARN_INIT and (not core.get_current_modname or
- name ~= core.get_current_modname()) then
- warn(("Global variable %q created at %s.")
+ if WARN_INIT and name ~= core.get_current_modname() then
+ core.log("warning", ("Global variable %q created at %s.")
:format(name, desc))
end
rawset(self, name, value)
@@ -48,7 +42,7 @@ function meta:__index(name)
local info = debug.getinfo(2, "Sl")
local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name)
if not declared[name] and not warned[warn_key] and info.what ~= "C" then
- warn(("Undeclared global variable %q accessed at %s:%s")
+ core.log("warning", ("Undeclared global variable %q accessed at %s:%s")
:format(name, info.short_src, info.currentline))
warned[warn_key] = true
end