summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/core/diagnostics.lua32
1 files changed, 12 insertions, 20 deletions
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index ff030348..84d3578c 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -44,13 +44,6 @@ function mt:searchUndefinedGlobal(callback)
for name in pairs(config.config.diagnostics.globals) do
definedGlobal[name] = true
end
- local envValue = self.vm.env:getValue()
- envValue:eachInfo(function (info)
- if info.type == 'set child' then
- local name = info[1]
- definedGlobal[name] = true
- end
- end)
self.vm:eachSource(function (source)
if not source:get 'global' then
return
@@ -63,23 +56,22 @@ function mt:searchUndefinedGlobal(callback)
if not value then
return
end
- if not value:isGlobal() then
- -- 上文重载了 _ENV 的情况
- local ok = value:eachInfo(function (info)
- if info.type == 'set' then
- return true
- end
- end)
- if ok then
- return
- end
- callback(source.start, source.finish, name)
+ if definedGlobal[name] then
return
end
- if definedGlobal[name] then
+ local parent = source:get 'parent'
+ if not parent then
return
end
- if type(name) ~= 'string' then
+ local ok = parent:eachInfo(function (info, src)
+ if info.type == 'set child' and info[1] == name then
+ return true
+ end
+ if src == source then
+ return false
+ end
+ end)
+ if ok then
return
end
callback(source.start, source.finish, name)