diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-18 18:14:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-18 18:14:49 +0800 |
commit | d00dfe1afcf6366a13cb4372b2328d80a8e8b3e9 (patch) | |
tree | 4ba3c479a10bd1b4677eb25d78c30faf1b4a2200 | |
parent | 509a1cf3ffbaf390c22c3c446e15d684f69b63ce (diff) | |
download | lua-language-server-d00dfe1afcf6366a13cb4372b2328d80a8e8b3e9.zip |
修正往_G里塞值会导致未声明全局变量判断错误的BUG
-rw-r--r-- | server/src/matcher/diagnostics.lua | 17 | ||||
-rw-r--r-- | server/test/diagnostics/init.lua | 5 |
2 files changed, 14 insertions, 8 deletions
diff --git a/server/src/matcher/diagnostics.lua b/server/src/matcher/diagnostics.lua index 07076b08..e7dfb533 100644 --- a/server/src/matcher/diagnostics.lua +++ b/server/src/matcher/diagnostics.lua @@ -27,14 +27,15 @@ local function searchUndefinedGlobal(results, callback) if field.value.lib then goto NEXT_VAR end - if type(index) == 'string' then - local lIndex = index:lower() - if lIndex == 'log' or lIndex == 'arg' then - goto NEXT_VAR - end - if not index:find '%l' then - goto NEXT_VAR - end + if type(index) ~= 'string' then + goto NEXT_VAR + end + local lIndex = index:lower() + if lIndex == 'log' or lIndex == 'arg' then + goto NEXT_VAR + end + if not index:find '%l' then + goto NEXT_VAR end if #field >= 3 then goto NEXT_VAR diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua index 83725a33..8cfbe4f2 100644 --- a/server/test/diagnostics/init.lua +++ b/server/test/diagnostics/init.lua @@ -126,3 +126,8 @@ local function x(a, b) end x(1, 2, <!3!>) ]] + +TEST [[ +instanceName = 1 +instance = _G[instanceName] +]] |