diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-21 17:28:28 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-21 17:28:28 +0800 |
commit | 3ef04652c31fa95ce1749f0309566f386ec70854 (patch) | |
tree | b6ead9b90d1268f71885c42b93b6ddf416d7f09a /server-beta/test | |
parent | 88373142ae448513f598cd49119862648658bb17 (diff) | |
download | lua-language-server-3ef04652c31fa95ce1749f0309566f386ec70854.zip |
更新类型推断
Diffstat (limited to 'server-beta/test')
-rw-r--r-- | server-beta/test/type_inference/init.lua | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/server-beta/test/type_inference/init.lua b/server-beta/test/type_inference/init.lua index c81fc15d..0ec0ea19 100644 --- a/server-beta/test/type_inference/init.lua +++ b/server-beta/test/type_inference/init.lua @@ -161,51 +161,55 @@ TEST 'table' [[ <?x?> = setmetatable({}) ]] -TEST 'number' [[ +TEST 'integer' [[ local function x() return 1 end <?y?> = x() ]] -TEST 'number' [[ -local function x(a) - return <?a?> -end -x(1) -]] +-- 不根据调用者的输入参数来推测 +--TEST 'number' [[ +--local function x(a) +-- return <?a?> +--end +--x(1) +--]] TEST 'table' [[ setmetatable(<?b?>) ]] -TEST 'number' [[ -local function x(a) - _ = a + 1 -end -local b -x(<?b?>) -]] - -TEST 'number' [[ -local function x(a, ...) - local _, <?b?>, _ = ... -end -x(nil, 'xx', 1, true) -]] - -TEST 'number' [[ -local function x(a, ...) - return true, 'ss', ... -end -local _, _, _, <?b?>, _ = x(nil, true, 1, 'yy') -]] - -TEST 'integer' [[ -for <?i?> in ipairs(t) do -end -]] - -TEST 'any' [[ -local <?x?> = next() -]] +-- 不根据对方函数内的使用情况来推测 +--TEST 'number' [[ +--local function x(a) +-- _ = a + 1 +--end +--local b +--x(<?b?>) +--]] + +--TEST 'number' [[ +--local function x(a, ...) +-- local _, <?b?>, _ = ... +--end +--x(nil, 'xx', 1, true) +--]] + +-- 引用不跨越参数 +--TEST 'number' [[ +--local function x(a, ...) +-- return true, 'ss', ... +--end +--local _, _, _, <?b?>, _ = x(nil, true, 1, 'yy') +--]] + +-- 暂不支持这些特殊情况,之后用其他语法定义 +--TEST 'integer' [[ +--for <?i?> in ipairs(t) do +--end +--]] +-- +--TEST 'any' [[ +--local <?x?> = next() +--]] |