diff options
-rw-r--r-- | script/vm/runner.lua | 4 | ||||
-rw-r--r-- | test/type_inference/init.lua | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/script/vm/runner.lua b/script/vm/runner.lua index c0218a44..30d9e672 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -114,6 +114,9 @@ end ---@param outNode? vm.node ---@return vm.node function mt:_lookInto(action, topNode, outNode) + if action.type == 'setlocal' then + topNode = self:_fastWard(action.finish, topNode) + end action = vm.getObjectValue(action) or action if action.type == 'function' or action.type == 'loop' @@ -162,6 +165,7 @@ function mt:_lookInto(action, topNode, outNode) goto RETURN end if action.op.type == 'not' then + outNode = outNode or topNode:copy() outNode, topNode = self:_lookInto(action[1], topNode, outNode) end elseif action.type == 'binary' then diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 2dd6971b..655f963d 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -2420,3 +2420,11 @@ TEST '`1`|`true`' [[ ---@type `1` | `true` local <?x?> ]] + +TEST 'function' [[ +local x + +function x() end + +print(<?x?>) +]] |