Skip to content

Commit 4876ff3

Browse files
committed
check nils
1 parent f8551a9 commit 4876ff3

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

script/vm/compiler.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ local compilerSwitch = util.switch()
980980
for _, doc in ipairs(src.bindDocs) do
981981
if doc.type == 'doc.type' then
982982
vm.setNode(src, vm.compileNode(doc), true)
983-
return
983+
return vm.getNode(src)
984984
end
985985
end
986986
end
@@ -1773,6 +1773,7 @@ local function compileByGlobal(source)
17731773
vm.setNode(source, globalNode, true)
17741774
return
17751775
end
1776+
---@type vm.node
17761777
globalNode = vm.createNode(global)
17771778
vm.setNode(root._globalBase[name], globalNode, true)
17781779
vm.setNode(source, globalNode, true)

script/vm/doc.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ function vm.isMetaFile(uri)
2727
return false
2828
end
2929
local cache = files.getCache(uri)
30+
if not cache then
31+
return false
32+
end
3033
if cache.isMeta ~= nil then
3134
return cache.isMeta
3235
end
@@ -332,6 +335,9 @@ function vm.isDiagDisabledAt(uri, position, name)
332335
return false
333336
end
334337
local cache = files.getCache(uri)
338+
if not cache then
339+
return false
340+
end
335341
if not cache.diagnosticRanges then
336342
cache.diagnosticRanges = {}
337343
for _, doc in ipairs(status.ast.docs) do

script/workspace/workspace.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ function m.findUrisByFilePath(path)
332332
return results
333333
end
334334

335+
---@param path string
336+
---@return string
335337
function m.normalize(path)
336338
if not path then
337339
return nil

test/command/auto-require.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local files = require 'files'
33
local autoRequire = require 'core.command.autoRequire'
44
local client = require 'client'
55

6-
local findInsertRow = util.getUpvalue(autoRequire, 'findInsertRow')
6+
local findInsertRow = util.getUpvalue(autoRequire, 'findInsertRow')
77
local applyAutoRequire = util.getUpvalue(autoRequire, 'applyAutoRequire')
88

99
local originEditText = client.editText

0 commit comments

Comments
 (0)