summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/locale/en-US/script.lni1
-rw-r--r--server/locale/zh-CN/script.lni1
-rw-r--r--server/src/core/diagnostics.lua27
3 files changed, 18 insertions, 11 deletions
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni
index 1021c58c..354d981d 100644
--- a/server/locale/en-US/script.lni
+++ b/server/locale/en-US/script.lni
@@ -3,6 +3,7 @@ DIAG_LINE_POST_SPACE = 'Line with postspace.'
DIAG_UNUSED_LOCAL = 'Unused local `{}`.'
DIAG_UNDEF_GLOBAL = 'Undefined global `{}`.'
DIAG_UNDEF_ENV_CHILD = 'Undefined variable `{}` (overloaded `_ENV` ).'
+DIAG_UNDEF_FENV_CHILD = 'Undefined variable `{}` (inside module).'
DIAG_UNUSED_LABEL = 'Unused label `{}`.'
DIAG_REDEFINED_LOCAL = 'Redefined local `{}`.'
DIAG_PREVIOUS_CALL = 'Parsed as function call for the previous line. It may be necessary to add a `;` before.'
diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni
index 5d090d06..72db5495 100644
--- a/server/locale/zh-CN/script.lni
+++ b/server/locale/zh-CN/script.lni
@@ -3,6 +3,7 @@ DIAG_LINE_POST_SPACE = '后置空格。'
DIAG_UNUSED_LOCAL = '未使用的局部变量 `{}`。'
DIAG_UNDEF_GLOBAL = '未定义的全局变量 `{}`。'
DIAG_UNDEF_ENV_CHILD = '未定义的变量 `{}`(重载了 `_ENV` )。'
+DIAG_UNDEF_FENV_CHILD = '未定义的变量 `{}`(处于模块中)。'
DIAG_UNUSED_LABEL = '未使用的标签 `{}`。'
DIAG_REDEFINED_LOCAL = '重定义局部变量 `{}`。'
DIAG_PREVIOUS_CALL = '解析为了上一行的函数调用。你可能需要在前面加一个 `;`。'
diff --git a/server/src/core/diagnostics.lua b/server/src/core/diagnostics.lua
index 600ee732..3e790fa3 100644
--- a/server/src/core/diagnostics.lua
+++ b/server/src/core/diagnostics.lua
@@ -308,15 +308,13 @@ function mt:searchUndefinedEnvChild(callback)
if parent:get 'ENV' then
return
end
- local ok = parent:eachInfo(function (info)
- if info.type == 'set child' and info[1] == name then
- return true
- end
- end)
- if ok then
+ local value = source:bindValue()
+ if not value then
return
end
- callback(source.start, source.finish, name)
+ if value:getSource() == source then
+ callback(source.start, source.finish, name)
+ end
return
end)
end
@@ -400,10 +398,17 @@ return function (vm, lines, uri)
end)
-- 未定义的变量(重载了 `_ENV`)
session:doDiagnostics(session.searchUndefinedEnvChild, 'undefined-env-child', function (key)
- return {
- level = DiagnosticSeverity.Information,
- message = lang.script('DIAG_UNDEF_ENV_CHILD', key),
- }
+ if vm.envType == '_ENV' then
+ return {
+ level = DiagnosticSeverity.Information,
+ message = lang.script('DIAG_UNDEF_ENV_CHILD', key),
+ }
+ else
+ return {
+ level = DiagnosticSeverity.Information,
+ message = lang.script('DIAG_UNDEF_FENV_CHILD', key),
+ }
+ end
end)
return session.datas
end