diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-28 16:28:33 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-28 16:28:33 +0800 |
commit | df4fb9b5157cbf11f3fc5f6041afef657f0acfba (patch) | |
tree | 84f65cb0adff35c8e2563d321dc99530010c5a6b /test/diagnostics/common.lua | |
parent | 7de3d6851a41d993b1f84eddd3331067a82e8878 (diff) | |
download | lua-language-server-df4fb9b5157cbf11f3fc5f6041afef657f0acfba.zip |
diag `missing-return`
Diffstat (limited to 'test/diagnostics/common.lua')
-rw-r--r-- | test/diagnostics/common.lua | 129 |
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') |