summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-03-08 21:17:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-03-08 21:17:43 +0800
commit48a3aab6e3becb5127ad467964c44f19187cac35 (patch)
tree87cbce0f6523c60100fbd69e4c9621120ba67d17 /script
parentf462813bee496adb2613389b0bfbb3e558617916 (diff)
downloadlua-language-server-48a3aab6e3becb5127ad467964c44f19187cac35.zip
don't treat `_ENV` as param
fix #1715
Diffstat (limited to 'script')
-rw-r--r--script/core/diagnostics/global-in-nil-env.lua3
-rw-r--r--script/parser/guide.lua13
2 files changed, 16 insertions, 0 deletions
diff --git a/script/core/diagnostics/global-in-nil-env.lua b/script/core/diagnostics/global-in-nil-env.lua
index e154080c..daf1f99d 100644
--- a/script/core/diagnostics/global-in-nil-env.lua
+++ b/script/core/diagnostics/global-in-nil-env.lua
@@ -13,6 +13,9 @@ return function (uri, callback)
if node.tag == '_ENV' then
return
end
+ if guide.isParam(node) then
+ return
+ end
if not node.value or node.value.type == 'nil' then
callback {
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index ec5746c1..e7eb3751 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1276,4 +1276,17 @@ function m.getTopBlock(source)
return nil
end
+---@param source parser.object
+---@return boolean
+function m.isParam(source)
+ if source.type ~= 'local'
+ and source.type ~= 'self' then
+ return false
+ end
+ if source.parent.type ~= 'funcargs' then
+ return false
+ end
+ return true
+end
+
return m