Skip to content

Commit a310a97

Browse files
committed
stash
1 parent 2dfed8a commit a310a97

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

script/files.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ local encoder = require 'encoder'
1515
local scope = require 'workspace.scope'
1616

1717
---@class file
18+
---@field uri uri
1819
---@field content string
1920
---@field _ref? integer
2021
---@field trusted? boolean
@@ -148,6 +149,9 @@ function m.exists(uri)
148149
return m.fileMap[uri] ~= nil
149150
end
150151

152+
---@param file file
153+
---@param text string
154+
---@return string
151155
local function pluginOnSetText(file, text)
152156
local plugin = require 'plugin'
153157
file._diffInfo = nil

script/parser/guide.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,16 +1090,20 @@ function m.getPath(a, b, sameFunction)
10901090
local pathB = {}
10911091
for _ = 1, 1000 do
10921092
objA = m.getParentBlock(objA)
1093-
pathA[#pathA+1] = objA
1094-
if (not sameFunction and objA.type == 'function') or objA.type == 'main' then
1095-
break
1093+
if objA then
1094+
pathA[#pathA+1] = objA
1095+
if (not sameFunction and objA.type == 'function') or objA.type == 'main' then
1096+
break
1097+
end
10961098
end
10971099
end
10981100
for _ = 1, 1000 do
10991101
objB = m.getParentBlock(objB)
1100-
pathB[#pathB+1] = objB
1101-
if (not sameFunction and objA.type == 'function') or objB.type == 'main' then
1102-
break
1102+
if objB then
1103+
pathB[#pathB+1] = objB
1104+
if (not sameFunction and objB.type == 'function') or objB.type == 'main' then
1105+
break
1106+
end
11031107
end
11041108
end
11051109
-- pathA: {1, 2, 3, 4, 5}

script/vm/infer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function mt:viewLiterals()
433433
or n.type == 'integer'
434434
or n.type == 'boolean' then
435435
local literal = util.viewLiteral(n[1])
436-
if not mark[literal] then
436+
if literal and not mark[literal] then
437437
literals[#literals+1] = literal
438438
mark[literal] = true
439439
end

test/type_inference/init.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3281,3 +3281,27 @@ local b
32813281
local c = a and b
32823282
local <?d?> = a or b
32833283
]]
3284+
3285+
TEST 'number' [[
3286+
local x
3287+
3288+
---@return number
3289+
local function f()
3290+
end
3291+
3292+
x = f()
3293+
3294+
print(<?x?>)
3295+
]]
3296+
3297+
TEST 'number' [[
3298+
local x
3299+
3300+
---@return number
3301+
local function f()
3302+
end
3303+
3304+
_, x = pcall(f)
3305+
3306+
print(<?x?>)
3307+
]]

0 commit comments

Comments
 (0)