fix: regression related to type narrow and generic since v3.10.1 #2898
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.
While giving reply in an old issue, I found a regression issue related to
@overload
and@generic
: #723 (comment)After doing git bisect, I found that it is introduced in this commit of
v3.10.1
: 8ecec08Minimal Example
Expected Result
中文版
我在回覆一個舊 issue 的時候,發現一個關於
@overload
及@generic
的 regression 問題,具體例子見上邊。大概是當 function 同時有 overload 和 generic param,並且 overload 的 function signature 比帶 generic 的短 就會觸發 (?)
用 git bisect 找到是這個 commit 開始出現的: 8ecec08
這個 commit 當時是為了 fix #2765 所引起的 runtime error,所以可以肯定是 bugfix commit 引起了不知明 side effect 🤔
估計成因
call.args
能在 type narrow 後做 recompute,所以直接把call.args
的 node cache 刪掉了,但卻有可能引起 runtime errorcall.args
node cache 先設成 empty 來解決 runtime errorcall.args
的 node cache 本身未存在,就直接設成 empty object,反而會引起之後的 infer 錯誤=> empty infer => 就是
unknown
🤔vm.getNode()
存在 時,才會 overwrite 成 empty new node