File tree 3 files changed +85
-0
lines changed
3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 3
3
## 3.2.4
4
4
* ` FIX ` hover: can not union ` table ` with other basic types
5
5
* ` FIX ` [ #1125 ] ( https://github.com/sumneko/lua-language-server/issues/1125 )
6
+ * ` FIX ` [ #1131 ] ( https://github.com/sumneko/lua-language-server/issues/1131 )
6
7
7
8
## 3.2.3
8
9
` 2022-5-16 `
Original file line number Diff line number Diff line change @@ -3,11 +3,69 @@ local guide = require 'parser.guide'
3
3
local vm = require ' vm'
4
4
local lang = require ' language'
5
5
6
+ --- @param source parser.object
7
+ --- @return integer
8
+ local function countReturns (source )
9
+ local n = 0
10
+
11
+ local docs = source .bindDocs
12
+ if docs then
13
+ for _ , doc in ipairs (docs ) do
14
+ if doc .type == ' doc.return' then
15
+ for _ , rtn in ipairs (doc .returns ) do
16
+ if rtn .returnIndex and rtn .returnIndex > n then
17
+ n = rtn .returnIndex
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+
24
+ local returns = source .returns
25
+ if returns then
26
+ for _ , rtn in ipairs (returns ) do
27
+ if # rtn > n then
28
+ n = # rtn
29
+ end
30
+ end
31
+ end
32
+
33
+ return n
34
+ end
35
+
36
+ local function countMaxReturns (source )
37
+ local hasFounded
38
+ local n = 0
39
+ for _ , def in ipairs (vm .getDefs (source )) do
40
+ if def .type == ' doc.type.function'
41
+ or def .type == ' function' then
42
+ hasFounded = true
43
+ local rets = countReturns (def )
44
+ if rets > n then
45
+ n = rets
46
+ end
47
+ end
48
+ end
49
+
50
+ if hasFounded then
51
+ return n
52
+ else
53
+ return math.huge
54
+ end
55
+ end
56
+
6
57
local function countCallArgs (source )
7
58
local result = 0
8
59
if not source .args then
9
60
return 0
10
61
end
62
+ local lastArg = source .args [# source .args ]
63
+ if lastArg .type == ' varargs' then
64
+ return math.huge
65
+ end
66
+ if lastArg .type == ' call' then
67
+ result = result + countMaxReturns (lastArg ) - 1
68
+ end
11
69
result = result + # source .args
12
70
return result
13
71
end
Original file line number Diff line number Diff line change 282
282
x(1, 2)
283
283
]]
284
284
285
+ TEST [[
286
+ ---@diagnostic disable: unused-local
287
+
288
+ ---@param a integer
289
+ ---@param b integer
290
+ local function f(a, b)
291
+ end
292
+
293
+ f(...)
294
+ ]]
295
+
296
+ TEST [[
297
+ ---@diagnostic disable: unused-local
298
+
299
+ ---@param a integer
300
+ ---@param b integer
301
+ local function f(a, b)
302
+ end
303
+
304
+ local function return2Numbers()
305
+ return 1, 2
306
+ end
307
+
308
+ f(return2Numbers())
309
+ ]]
310
+
285
311
TEST [[
286
312
---@param a integer
287
313
---@param b? integer
You can’t perform that action at this time.
0 commit comments