feat: infer function param when the function is passed as call arg #2946
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #2695 (the feature request by me, finally I have the knowledge to implement myself 🙂 )
fun()
annotation.Lua.type.inferParamType
logic, so this feature is only enabled when this config is set totrue
.Example Use Case
which is similar to existing infer behavior with function literal:
中文版
Lua.type.inferParamType
功能的延伸,所以要開啟這個 config 才會生效實現思路
如果這個 function variable 是在某次 call 中作為 arg
應該是可以嘗試用該 arg 位置的
doc.type.function
(如有) 來進一步 infer@function
annotation) #1456 (comment)我找到原來有1個
vm.compileCallArg()
可以 compile 某個 call 行為的指定 index argument typecbIndex
的 arg infer typedoc.type.function
,則再利用這 function 的args[aindex]
(當前 local function param index) 的 type 來做 infer