summaryrefslogtreecommitdiff
path: root/script/vm/compiler.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-01-17 17:44:40 +0800
committerGitHub <noreply@github.com>2024-01-17 17:44:40 +0800
commit34319c7990cba47ddc00e77aabfccbb923f84e26 (patch)
treedb57cf9717f892c1cc9ef15dace9e87707b4310e /script/vm/compiler.lua
parentef7157c450254b0ee447960b0cb06d6f1b0dbaaa (diff)
parenta90d1d2c4990fed2db4ac5b2341ff12193389c1c (diff)
downloadlua-language-server-34319c7990cba47ddc00e77aabfccbb923f84e26.zip
Merge pull request #2481 from fesily/automatic-derivation-function-param-type
Automatic derivation function param type
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r--script/vm/compiler.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 8a1fa96a..2222fa9b 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1090,6 +1090,35 @@ local function compileLocal(source)
end
end
end
+ if not hasDocArg
+ and func.parent.type == 'local' then
+ local refs = func.parent.ref
+ local findCall
+ if refs then
+ for i, ref in ipairs(refs) do
+ if ref.parent.type == 'call' then
+ findCall = ref.parent
+ break
+ end
+ end
+ end
+ if findCall and findCall.args then
+ local index
+ for i, arg in ipairs(source.parent) do
+ if arg == source then
+ index = i
+ break
+ end
+ end
+ if index then
+ local callerArg = findCall.args[index]
+ if callerArg then
+ hasDocArg = true
+ vm.setNode(source, vm.compileNode(callerArg))
+ end
+ end
+ end
+ end
if not hasDocArg then
vm.setNode(source, vm.declareGlobal('type', 'any'))
end