Skip to content

Commit ae02495

Browse files
committed
fix diags
1 parent f3019c6 commit ae02495

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

locale/zh-cn/script.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ DIAG_CAST_TYPE_MISMATCH =
130130
'不能将 `{ref}` 转换为 `{def}`。'
131131
DIAG_MISSING_RETURN_VALUE =
132132
'至少需要 {min} 个返回值,但此处只返回 {rmax} 个值。'
133-
DIAG_MISSING_RETURN_VALUE =
133+
DIAG_MISSING_RETURN_VALUE_RANGE =
134134
'至少需要 {min} 个返回值,但此处只返回 {rmin} 到 {rmax} 个值。'
135135

136136
MWS_NOT_SUPPORT =

script/core/diagnostics/missing-return-value.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ return function (uri, callback)
4949
callback {
5050
start = ret.start,
5151
finish = ret.start + #'return',
52-
message = lang.script('DIAG_MISSING_RETURN_VALUE', {
52+
message = lang.script('DIAG_MISSING_RETURN_VALUE_RANGE', {
5353
min = min,
5454
rmin = rmin,
5555
rmax = rmax,

script/parser/compile.lua

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,13 @@ end
269269
---@return string word
270270
---@return parser.position startPosition
271271
---@return parser.position finishPosition
272-
---@return integer newOffset
273272
local function peekWord()
274273
local word = Tokens[Index + 1]
275274
if not word then
276-
return nil
275+
return nil, nil, nil
277276
end
278277
if not CharMapWord[ssub(word, 1, 1)] then
279-
return nil
278+
return nil, nil, nil
280279
end
281280
local startPos = getPosition(Tokens[Index] , 'left')
282281
local finishPos = getPosition(Tokens[Index] + #word - 1, 'right')
@@ -2598,29 +2597,29 @@ local function parseSetValues()
25982597
skipSpace()
25992598
local first = parseExp()
26002599
if not first then
2601-
return nil
2600+
return nil, nil, nil
26022601
end
26032602
skipSpace()
26042603
if Tokens[Index + 1] ~= ',' then
2605-
return first
2604+
return first, nil, nil
26062605
end
26072606
Index = Index + 2
26082607
skipSeps()
26092608
local second = parseExp()
26102609
if not second then
26112610
missExp()
2612-
return first
2611+
return first, nil, nil
26132612
end
26142613
skipSpace()
26152614
if Tokens[Index + 1] ~= ',' then
2616-
return first, second
2615+
return first, second, nil
26172616
end
26182617
Index = Index + 2
26192618
skipSeps()
26202619
local third = parseExp()
26212620
if not third then
26222621
missExp()
2623-
return first, second
2622+
return first, second, nil
26242623
end
26252624

26262625
local rest = { third }
@@ -2652,29 +2651,29 @@ end
26522651
---@return parser.object[] rest
26532652
local function parseVarTails(parser, isLocal)
26542653
if Tokens[Index + 1] ~= ',' then
2655-
return
2654+
return nil, nil
26562655
end
26572656
Index = Index + 2
26582657
skipSpace()
26592658
local second = parser(true)
26602659
if not second then
26612660
missName()
2662-
return
2661+
return nil, nil
26632662
end
26642663
if isLocal then
26652664
createLocal(second, parseLocalAttrs())
26662665
second.effect = maxinteger
26672666
end
26682667
skipSpace()
26692668
if Tokens[Index + 1] ~= ',' then
2670-
return second
2669+
return second, nil
26712670
end
26722671
Index = Index + 2
26732672
skipSeps()
26742673
local third = parser(true)
26752674
if not third then
26762675
missName()
2677-
return second
2676+
return second, nil
26782677
end
26792678
if isLocal then
26802679
createLocal(third, parseLocalAttrs())

script/parser/guide.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,13 +1089,13 @@ end
10891089
--- 返回的2个 `list` 分别为基准block到达 a 与 b 的路径。
10901090
---@param a table
10911091
---@param b table
1092-
---@return string|boolean mode
1092+
---@return string|false mode
10931093
---@return table pathA?
10941094
---@return table pathB?
10951095
function m.getPath(a, b, sameFunction)
10961096
--- 首先测试双方在同一个函数内
10971097
if sameFunction and m.getParentFunction(a) ~= m.getParentFunction(b) then
1098-
return false
1098+
return false, nil, nil
10991099
end
11001100
local mode
11011101
local objA
@@ -1139,7 +1139,7 @@ function m.getPath(a, b, sameFunction)
11391139
end
11401140
end
11411141
if not start then
1142-
return nil
1142+
return false, nil, nil
11431143
end
11441144
-- pathA: { 1, 2, 3}
11451145
-- pathB: {5, 6, 2, 3}

script/parser/luadoc.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ local function nextToken()
165165
Ci = Ci + 1
166166
if not TokenTypes[Ci] then
167167
Ci = Ci - 1
168-
return nil
168+
return nil, nil
169169
end
170170
return TokenTypes[Ci], TokenContents[Ci]
171171
end

test/diagnostics/common.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,16 +1736,17 @@ end
17361736

17371737
do return end
17381738
TEST [[
1739-
---@return number
1739+
---@return number, number?
17401740
function F()
1741-
X = 1<!!>
1741+
return 1, 1, <!1!>
17421742
end
17431743
]]
17441744

17451745
TEST [[
1746-
---@return number, number?
1746+
---@return number
17471747
function F()
1748-
return 1, 1, <!1!>
1748+
X = 1<!!>
17491749
end
17501750
]]
1751+
17511752
util.arrayRemove(disables, 'redundant-return')

0 commit comments

Comments
 (0)