diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-13 21:54:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-13 21:54:31 +0800 |
commit | 0a3e6482362eb35948cc0c744e089ff491104580 (patch) | |
tree | 5011ecb52a0be0a744f29d0887583359b7411579 | |
parent | 2e9cdbe7f0bb48bd5e6321dd968f995913b5da42 (diff) | |
download | lua-language-server-0a3e6482362eb35948cc0c744e089ff491104580.zip |
会根据函数参数推测调用者的类型
-rw-r--r-- | server/src/matcher/vm.lua | 6 | ||||
-rw-r--r-- | server/test/type_inference/init.lua | 4 |
2 files changed, 9 insertions, 1 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 2f7bbcf4..af3e00ed 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -325,7 +325,11 @@ function mt:setFunctionArg(func, values) func.argValues = {} end for i = 1, #values do - func.argValues[i] = values[i] + if not func.argValues[i] then + func.argValues[i] = values[i] + end + self:inference(values[i], func.argValues[i].type) + self:inference(func.argValues[i], values[i].type) end self:updateFunctionArgs(func) diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua index 8f5909c0..733fd99a 100644 --- a/server/test/type_inference/init.lua +++ b/server/test/type_inference/init.lua @@ -146,3 +146,7 @@ local function x(a) end x(1) ]] + +TEST 'table' [[ +setmetatable(<?b?>) +]] |