File tree Expand file tree Collapse file tree 3 files changed +85
-0
lines changed
Expand file tree Collapse file tree 3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change 33## 3.2.4
44* ` FIX ` hover: can not union ` table ` with other basic types
55* ` FIX ` [ #1125 ] ( https://github.com/sumneko/lua-language-server/issues/1125 )
6+ * ` FIX ` [ #1131 ] ( https://github.com/sumneko/lua-language-server/issues/1131 )
67
78## 3.2.3
89` 2022-5-16 `
Original file line number Diff line number Diff line change @@ -3,11 +3,69 @@ local guide = require 'parser.guide'
33local vm = require ' vm'
44local lang = require ' language'
55
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+
657local function countCallArgs (source )
758 local result = 0
859 if not source .args then
960 return 0
1061 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
1169 result = result + # source .args
1270 return result
1371end
Original file line number Diff line number Diff line change 282282x(1, 2)
283283]]
284284
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+
285311TEST [[
286312---@param a integer
287313---@param b? integer
You can’t perform that action at this time.
0 commit comments