summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md3
-rw-r--r--script/core/completion.lua6
-rw-r--r--script/files.lua3
-rw-r--r--script/parser/guide.lua3
-rw-r--r--script/workspace/workspace.lua3
5 files changed, 16 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md
index c35052dd..9f73473c 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,8 @@
# changelog
+## 1.16.1
+* `FIX` runtime errors
+
## 1.16.0
`2021-2-20`
* `NEW` file encoding supports `ansi`
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 2e773fa5..17ccb817 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1358,7 +1358,7 @@ end
local function checkTableLiteralField(ast, text, offset, call, funcs, index, results)
local source = findNearestSource(ast, offset)
if source.type ~= 'table'
- and source.parent.type ~= 'table' then
+ and (not source.parent or source.parent.type ~= 'table') then
return
end
if call.node and call.node.type == 'getmethod' then
@@ -1372,7 +1372,9 @@ local function checkTableLiteralField(ast, text, offset, call, funcs, index, res
end
for _, field in ipairs(vm.getDefFields(tbl, 0)) do
local name = guide.getKeyName(field)
- mark[name] = true
+ if name then
+ mark[name] = true
+ end
end
for _, func in ipairs(funcs) do
local param = getFuncParamByCallIndex(func, index)
diff --git a/script/files.lua b/script/files.lua
index af6be58c..6dab8a01 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -39,6 +39,9 @@ m.astMap = setmetatable({}, { __mode = 'v' })
local uriMap = {}
local function getUriKey(uri)
+ if not uri then
+ return nil
+ end
if not uriMap[uri] then
if platform.OS == 'Windows' then
uriMap[uri] = uri:lower()
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index b099dd9b..98dca211 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -2941,6 +2941,9 @@ function m.getRefCache(status, obj, mode)
if m.isGlobal(obj) then
obj = m.getKeyName(obj)
end
+ if not obj then
+ return {}
+ end
if not globalCache[mode] then
globalCache[mode] = {}
end
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index f222e907..667ac56f 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -435,6 +435,9 @@ function m.getRelativePath(uri)
end
function m.isWorkspaceUri(uri)
+ if not m.uri then
+ return false
+ end
local luri = files.getUri(uri)
local ruri = files.getUri(m.uri)
return luri:sub(1, #ruri) == ruri