summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--locale/zh-cn/script.lua2
-rw-r--r--script/core/diagnostics/missing-return-value.lua2
-rw-r--r--script/parser/compile.lua23
-rw-r--r--script/parser/guide.lua6
-rw-r--r--script/parser/luadoc.lua2
-rw-r--r--test/diagnostics/common.lua9
6 files changed, 22 insertions, 22 deletions
diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua
index ee6ce2b5..c0f478c3 100644
--- a/locale/zh-cn/script.lua
+++ b/locale/zh-cn/script.lua
@@ -130,7 +130,7 @@ DIAG_CAST_TYPE_MISMATCH =
'不能将 `{ref}` 转换为 `{def}`。'
DIAG_MISSING_RETURN_VALUE =
'至少需要 {min} 个返回值,但此处只返回 {rmax} 个值。'
-DIAG_MISSING_RETURN_VALUE =
+DIAG_MISSING_RETURN_VALUE_RANGE =
'至少需要 {min} 个返回值,但此处只返回 {rmin} 到 {rmax} 个值。'
MWS_NOT_SUPPORT =
diff --git a/script/core/diagnostics/missing-return-value.lua b/script/core/diagnostics/missing-return-value.lua
index 491475c7..c2e882e3 100644
--- a/script/core/diagnostics/missing-return-value.lua
+++ b/script/core/diagnostics/missing-return-value.lua
@@ -49,7 +49,7 @@ return function (uri, callback)
callback {
start = ret.start,
finish = ret.start + #'return',
- message = lang.script('DIAG_MISSING_RETURN_VALUE', {
+ message = lang.script('DIAG_MISSING_RETURN_VALUE_RANGE', {
min = min,
rmin = rmin,
rmax = rmax,
diff --git a/script/parser/compile.lua b/script/parser/compile.lua
index 9db46241..ac599030 100644
--- a/script/parser/compile.lua
+++ b/script/parser/compile.lua
@@ -269,14 +269,13 @@ end
---@return string word
---@return parser.position startPosition
---@return parser.position finishPosition
----@return integer newOffset
local function peekWord()
local word = Tokens[Index + 1]
if not word then
- return nil
+ return nil, nil, nil
end
if not CharMapWord[ssub(word, 1, 1)] then
- return nil
+ return nil, nil, nil
end
local startPos = getPosition(Tokens[Index] , 'left')
local finishPos = getPosition(Tokens[Index] + #word - 1, 'right')
@@ -2598,29 +2597,29 @@ local function parseSetValues()
skipSpace()
local first = parseExp()
if not first then
- return nil
+ return nil, nil, nil
end
skipSpace()
if Tokens[Index + 1] ~= ',' then
- return first
+ return first, nil, nil
end
Index = Index + 2
skipSeps()
local second = parseExp()
if not second then
missExp()
- return first
+ return first, nil, nil
end
skipSpace()
if Tokens[Index + 1] ~= ',' then
- return first, second
+ return first, second, nil
end
Index = Index + 2
skipSeps()
local third = parseExp()
if not third then
missExp()
- return first, second
+ return first, second, nil
end
local rest = { third }
@@ -2652,14 +2651,14 @@ end
---@return parser.object[] rest
local function parseVarTails(parser, isLocal)
if Tokens[Index + 1] ~= ',' then
- return
+ return nil, nil
end
Index = Index + 2
skipSpace()
local second = parser(true)
if not second then
missName()
- return
+ return nil, nil
end
if isLocal then
createLocal(second, parseLocalAttrs())
@@ -2667,14 +2666,14 @@ local function parseVarTails(parser, isLocal)
end
skipSpace()
if Tokens[Index + 1] ~= ',' then
- return second
+ return second, nil
end
Index = Index + 2
skipSeps()
local third = parser(true)
if not third then
missName()
- return second
+ return second, nil
end
if isLocal then
createLocal(third, parseLocalAttrs())
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index 439f5889..1ba28d4d 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1089,13 +1089,13 @@ end
--- 返回的2个 `list` 分别为基准block到达 a 与 b 的路径。
---@param a table
---@param b table
----@return string|boolean mode
+---@return string|false mode
---@return table pathA?
---@return table pathB?
function m.getPath(a, b, sameFunction)
--- 首先测试双方在同一个函数内
if sameFunction and m.getParentFunction(a) ~= m.getParentFunction(b) then
- return false
+ return false, nil, nil
end
local mode
local objA
@@ -1139,7 +1139,7 @@ function m.getPath(a, b, sameFunction)
end
end
if not start then
- return nil
+ return false, nil, nil
end
-- pathA: { 1, 2, 3}
-- pathB: {5, 6, 2, 3}
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 392b476f..e71c6f18 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -165,7 +165,7 @@ local function nextToken()
Ci = Ci + 1
if not TokenTypes[Ci] then
Ci = Ci - 1
- return nil
+ return nil, nil
end
return TokenTypes[Ci], TokenContents[Ci]
end
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua
index de2481a6..16773633 100644
--- a/test/diagnostics/common.lua
+++ b/test/diagnostics/common.lua
@@ -1736,16 +1736,17 @@ end
do return end
TEST [[
----@return number
+---@return number, number?
function F()
- X = 1<!!>
+ return 1, 1, <!1!>
end
]]
TEST [[
----@return number, number?
+---@return number
function F()
- return 1, 1, <!1!>
+ X = 1<!!>
end
]]
+
util.arrayRemove(disables, 'redundant-return')