summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/common.lua129
1 files changed, 128 insertions, 1 deletions
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua
index 2d56103b..86acbe0c 100644
--- a/test/diagnostics/common.lua
+++ b/test/diagnostics/common.lua
@@ -1759,7 +1759,6 @@ function F()
end
]]
-do return end
TEST [[
---@return number
function F()
@@ -1767,4 +1766,132 @@ function F()
end
]]
+TEST [[
+local A
+---@return number
+function F()
+ if A then
+ return 1
+ end<!!>
+end
+]]
+
+TEST [[
+local A, B
+---@return number
+function F()
+ if A then
+ return 1
+ elseif B then
+ return 2
+ end<!!>
+end
+]]
+
+TEST [[
+local A, B
+---@return number
+function F()
+ if A then
+ return 1
+ elseif B then
+ return 2
+ else
+ return 3
+ end
+end
+]]
+
+TEST [[
+local A, B
+---@return number
+function F()
+ if A then
+ elseif B then
+ return 2
+ else
+ return 3
+ end<!!>
+end
+]]
+
+TEST [[
+---@return any
+function F()
+ X = 1
+end
+]]
+
+TEST [[
+---@return any, number
+function F()
+ X = 1<!!>
+end
+]]
+
+TEST [[
+---@return number, any
+function F()
+ X = 1<!!>
+end
+]]
+
+TEST [[
+---@return any, any
+function F()
+ X = 1<!!>
+end
+]]
+
+TEST [[
+local A
+---@return number
+function F()
+ for _ = 1, 10 do
+ if A then
+ return 1
+ end
+ end
+ error('should not be here')
+end
+]]
+
+TEST [[
+local A
+---@return number
+function F()
+ while true do
+ if A then
+ return 1
+ end
+ end
+end
+]]
+
+TEST [[
+local A
+---@return number
+function F()
+ while A do
+ if A then
+ return 1
+ end
+ end<!!>
+end
+]]
+
+TEST [[
+local A
+---@return number
+function F()
+ while A do
+ if A then
+ return 1
+ else
+ return 2
+ end
+ end
+end
+]]
+
util.arrayRemove(disables, 'redundant-return')