diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-11-05 01:25:21 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-11-05 01:25:21 +0800 |
commit | b870bc090ce17747de961a713fc6333d2e6d401f (patch) | |
tree | 7c7ee13ecb233e62649a5ff982b7531a0c071e65 /script | |
parent | 82ccd9baf64bf739e0bf7f8251075acb9e286356 (diff) | |
download | lua-language-server-b870bc090ce17747de961a713fc6333d2e6d401f.zip |
infer parameter type by function type
#1457
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/compiler.lua | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 826c3742..9e8acb0a 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -1111,6 +1111,8 @@ local compilerSwitch = util.switch() : call(function (source) vm.setNode(source, source) + local parent = source.parent + if source.bindDocs then for _, doc in ipairs(source.bindDocs) do if doc.type == 'doc.overload' then @@ -1120,16 +1122,16 @@ local compilerSwitch = util.switch() end -- table.sort(string[], function (<?x?>) end) - if source.parent.type == 'callargs' then - local call = source.parent.parent + if parent.type == 'callargs' then + local call = parent.parent vm.compileCallArg(source, call) end -- function f() return function (<?x?>) end end - if source.parent.type == 'return' then - for i, ret in ipairs(source.parent) do + if parent.type == 'return' then + for i, ret in ipairs(parent) do if ret == source then - local func = guide.getParentFunction(source.parent) + local func = guide.getParentFunction(parent) if func then local returnObj = vm.getReturnOfFunction(func, i) if returnObj then @@ -1142,9 +1144,8 @@ local compilerSwitch = util.switch() end -- { f = function (<?x?>) end } - if source.parent.type == 'tablefield' - or source.parent.type == 'tableindex' then - vm.setNode(source, vm.compileNode(source.parent)) + if guide.isSet(parent) then + vm.setNode(source, vm.compileNode(parent)) end end) : case 'paren' |