summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-10-11 17:23:29 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-10-11 17:23:29 +0800
commit9d178dddbc3543ed6faa9bd9c23bed517774393f (patch)
treecafce119e29ebbc6b1d4dbe1a5163fa5913663a1 /script
parentfba7d2df87e418b93c2c45531de2f776a8747b20 (diff)
downloadlua-language-server-9d178dddbc3543ed6faa9bd9c23bed517774393f.zip
fix
Diffstat (limited to 'script')
-rw-r--r--script/core/diagnostics/ambiguity-1.lua3
-rw-r--r--script/core/infer.lua7
-rw-r--r--script/parser/guide.lua2
-rw-r--r--script/parser/newparser.lua3
4 files changed, 12 insertions, 3 deletions
diff --git a/script/core/diagnostics/ambiguity-1.lua b/script/core/diagnostics/ambiguity-1.lua
index 68e88e22..dbaa101d 100644
--- a/script/core/diagnostics/ambiguity-1.lua
+++ b/script/core/diagnostics/ambiguity-1.lua
@@ -37,6 +37,9 @@ return function (uri, callback)
end
local first = source[1]
local second = source[2]
+ if not first or not second then
+ return
+ end
-- a + (b or 0) --> (a + b) or 0
do
if opMap[first.op and first.op.type]
diff --git a/script/core/infer.lua b/script/core/infer.lua
index f1262d0e..925c040d 100644
--- a/script/core/infer.lua
+++ b/script/core/infer.lua
@@ -353,7 +353,7 @@ function m.getDocName(doc)
if doc.typeGeneric then
return '<' .. name .. '>'
else
- return name
+ return tostring(name)
end
end
if doc.type == 'doc.type.array' then
@@ -372,7 +372,7 @@ function m.getDocName(doc)
if doc.type == 'doc.type.enum'
or doc.type == 'doc.resume' then
local value = doc[1] or '?'
- return value
+ return tostring(value)
end
if doc.type == 'doc.type.ltable' then
return 'table'
@@ -574,6 +574,9 @@ end
function m.hasType(source, tp, mark)
mark = mark or {}
local infers = m.searchInfers(source, nil, mark)
+ if not infers then
+ return false
+ end
if infers[tp] then
return true
end
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 4046cd69..b6cce241 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -763,7 +763,7 @@ end
function m.positionToOffsetByLines(lines, position)
local row, col = m.rowColOf(position)
- return lines[row] + col - 1
+ return (lines[row] or 1) + col - 1
end
--- 返回全文光标位置
diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua
index 747c4f5c..2322e4a1 100644
--- a/script/parser/newparser.lua
+++ b/script/parser/newparser.lua
@@ -909,6 +909,9 @@ local function parseShortString()
stringPool[stringIndex] = ssub(Lua, currentOffset, Tokens[Index] - 1)
currentOffset = Tokens[Index]
Index = Index + 2
+ if not Tokens[Index] then
+ goto CONTINUE
+ end
-- has space?
if Tokens[Index] - currentOffset > 1 then
pushError {