summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-12-01 17:40:32 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-12-01 17:40:32 +0800
commit98dc39631314a2c6c788655c617c9c45d1cce51f (patch)
treebe4cb97d88ece8129b7ce6f39e78dc22183ecdb1
parent018ee6b9d5be0b58ffb04796b3910bf7f1b03e6a (diff)
downloadlua-language-server-98dc39631314a2c6c788655c617c9c45d1cce51f.zip
fix runtime errors
-rw-r--r--changelog.md1
-rw-r--r--script/core/definition.lua3
-rw-r--r--script/core/diagnostics/unused-function.lua3
-rw-r--r--script/core/infer.lua4
-rw-r--r--script/core/reference.lua3
5 files changed, 14 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 6a447922..79599185 100644
--- a/changelog.md
+++ b/changelog.md
@@ -5,6 +5,7 @@
* `FIX` [#825](https://github.com/sumneko/lua-language-server/issues/825)
* `FIX` [#827](https://github.com/sumneko/lua-language-server/issues/827)
* `FIX` [#837](https://github.com/sumneko/lua-language-server/issues/837)
+* `FIX` runtime errors
## 2.5.1
`2021-11-29`
diff --git a/script/core/definition.lua b/script/core/definition.lua
index d77ddac1..a1f46afc 100644
--- a/script/core/definition.lua
+++ b/script/core/definition.lua
@@ -155,6 +155,9 @@ return function (uri, offset)
or src.type == 'setindex'
or src.type == 'tableindex' then
src = src.index
+ if not src then
+ goto CONTINUE
+ end
if not guide.isLiteral(src) then
goto CONTINUE
end
diff --git a/script/core/diagnostics/unused-function.lua b/script/core/diagnostics/unused-function.lua
index 0e0c0003..79cb16e2 100644
--- a/script/core/diagnostics/unused-function.lua
+++ b/script/core/diagnostics/unused-function.lua
@@ -28,6 +28,9 @@ return function (uri, callback)
local cache = {}
---@async
local function checkFunction(source)
+ if not source then
+ return
+ end
if cache[source] ~= nil then
return cache[source]
end
diff --git a/script/core/infer.lua b/script/core/infer.lua
index 8da35289..39cb8c5e 100644
--- a/script/core/infer.lua
+++ b/script/core/infer.lua
@@ -598,6 +598,10 @@ function m.searchAndViewInfers(source, field, mark)
end
local infers = m.searchInfers(source, field, mark)
local view = m.viewInfers(infers)
+ if type(view) == 'boolean' then
+ log.error('Why view is boolean?', util.dump(infers))
+ return 'any'
+ end
return view
end
diff --git a/script/core/reference.lua b/script/core/reference.lua
index 067d2e23..5e4a4cbf 100644
--- a/script/core/reference.lua
+++ b/script/core/reference.lua
@@ -111,6 +111,9 @@ return function (uri, position)
elseif src.type == 'table' and src.parent.type ~= 'return' then
goto CONTINUE
end
+ if not src then
+ goto CONTINUE
+ end
results[#results+1] = {
target = src,
uri = root.uri,