diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-04 20:29:47 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-07-04 20:29:47 +0800 |
commit | 3e18b81da356588b9e9749092d9833ca85e88e26 (patch) | |
tree | f6a1ee5e2ca063e0918c3994c2ab573eea4618f9 | |
parent | 6f52414fc098886056d8060dde097626e5095126 (diff) | |
download | lua-language-server-3e18b81da356588b9e9749092d9833ca85e88e26.zip |
fix
-rw-r--r-- | script/vm/runner.lua | 2 | ||||
-rw-r--r-- | test/type_inference/init.lua | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua index ec3449ee..49626665 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -117,6 +117,7 @@ function mt:_lookIntoChild(action, topNode, outNode) return topNode, topNode or outNode end self._mark[action] = true + topNode = self:_fastWardCasts(action.start, topNode) if action.type == 'getlocal' then if action.node == self._loc then self._callback(action, topNode) @@ -323,7 +324,6 @@ function mt:_lookIntoBlock(block, topNode) end for _, action in ipairs(block) do if self._has[action] then - topNode = self:_fastWardCasts(action.start, topNode) topNode = self:_lookIntoChild(action, topNode) end end diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 50b3901d..02e9364e 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -3219,6 +3219,16 @@ local n print(<?n?>) ]] +TEST 'table' [[ +---@type number|table +local n + +if n +---@cast n table +and <?n?>.type == 'xxx' then +end +]] + TEST 'integer' [[ ---@type integer? local n |