diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 17:15:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-01-09 17:15:22 +0800 |
commit | c796d406329170e010590d7c9584b8483021cee3 (patch) | |
tree | a4f43228c38847acaf968aea1e46c8df3d88ec17 /test/type_inference | |
parent | 78875f59fe2fa846d62bf955805b647d17cf87d2 (diff) | |
download | lua-language-server-c796d406329170e010590d7c9584b8483021cee3.zip |
support trace for global
Diffstat (limited to 'test/type_inference')
-rw-r--r-- | test/type_inference/init.lua | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 0b69a34c..db1d306e 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -2893,10 +2893,7 @@ local <?x?> = echo(b) ]] TEST 'boolean' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2906,10 +2903,7 @@ local <?x?> = f() ]] TEST 'number' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2919,10 +2913,7 @@ local <?x?> = f(1) ]] TEST 'boolean' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2936,10 +2927,7 @@ local <?x?> = f(r0()) ]] TEST 'number' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2953,10 +2941,7 @@ local <?x?> = f(r1()) ]] TEST 'boolean' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -2969,10 +2954,7 @@ local <?x?> = f(r0()) ]] TEST 'number' [[ ----@return boolean -function f() -end - +---@overload fun():boolean ---@param x integer ---@return number function f(x) @@ -3430,7 +3412,7 @@ local mt = {} mt.<?x?> = nil ]] -TEST 'unknown' [[ +TEST 'nil' [[ mt = {} mt.<?x?> = nil ]] @@ -4148,3 +4130,30 @@ for _, <?x?> in ipairs(xs) do x = f(x) end ]] + +TEST 'number' [[ +---@type number? +X = Y + +if X then + print(<?X?>) +end +]] + +TEST 'number' [[ +---@type number|boolean +X = Y + +if type(X) == 'number' then + print(<?X?>) +end +]] + +TEST 'boolean' [[ +---@type number|boolean +X = Y + +if type(X) ~= 'number' then + print(<?X?>) +end +]] |