From 7e778b31476831864dff995ae3ae4e5f223c5726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 28 Jun 2022 19:09:39 +0800 Subject: new diag `return-type-mismatch` --- test/diagnostics/type-check.lua | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'test/diagnostics') diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index 34f7a492..d586c5de 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -496,5 +496,66 @@ TEST [[ local = 'aaa' ]] +TEST [[ +---@return number +function F() + return +end +]] + +TEST [[ +---@return number? +function F() + return 1 +end +]] + +TEST [[ +---@return number? +function F() + return nil +end +]] + +TEST [[ +---@return number, number +local function f() end + +---@return number, boolean +function F() + return +end +]] + +TEST [[ +---@return boolean, number +local function f() end + +---@return number, boolean +function F() + return +end +]] + +TEST [[ +---@return boolean, number? +local function f() end + +---@return number, boolean +function F() + return 1, f() +end +]] + +TEST [[ +---@return number, number? +local function f() end + +---@return number, boolean, number +function F() + return 1, +end +]] + config.remove(nil, 'Lua.diagnostics.disable', 'unused-local') config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global') -- cgit v1.2.3