diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-18 02:09:44 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-18 02:09:44 +0800 |
commit | c0b4b0299dc7b7efc667ef7fb0957e079ad8a411 (patch) | |
tree | d8c9219275f0ab6c85643a2f93571824023e1b9e | |
parent | 53d376ce281906fd856fac42073a072906b2628e (diff) | |
download | lua-language-server-c0b4b0299dc7b7efc667ef7fb0957e079ad8a411.zip |
update
-rw-r--r-- | script/vm/compiler.lua | 5 | ||||
-rw-r--r-- | test/type_inference/init.lua | 8 |
2 files changed, 11 insertions, 2 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 12ef2a7c..e33ec234 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -1418,11 +1418,12 @@ local compilerSwitch = util.switch() end end if lastReturn and not hasMarkDoc and lastReturn.types[1][1] == '...' then + hasMarkDoc = true vm.setNode(source, vm.getGlobal('type', 'unknown')) end end + local hasReturn if func.returns and not hasMarkDoc then - local hasReturn for _, rtn in ipairs(func.returns) do if selectNode(source, rtn, index) then hasReturn = true @@ -1454,7 +1455,7 @@ local compilerSwitch = util.switch() end end end - if vm.getNode(source):isEmpty() then + if not hasMarkDoc and not hasReturn then vm.setNode(source, vm.getGlobal('type', 'nil')) end end) diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index d706798b..74f149e0 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -2699,3 +2699,11 @@ end local <?n?> = f() ]] + +TEST 'unknown' [[ +local function f() + return t[k] +end + +local <?n?> = f() +]] |