diff options
-rw-r--r-- | script/vm/node.lua | 5 | ||||
-rw-r--r-- | script/vm/runner.lua | 1 | ||||
-rw-r--r-- | test/type_inference/init.lua | 14 |
3 files changed, 20 insertions, 0 deletions
diff --git a/script/vm/node.lua b/script/vm/node.lua index 65a2108f..49207b13 100644 --- a/script/vm/node.lua +++ b/script/vm/node.lua @@ -216,6 +216,11 @@ function mt:setFalsy() self[c] = nil goto CONTINUE end + if guide.isLiteral(c) then + table.remove(self, index) + self[c] = nil + goto CONTINUE + end ::CONTINUE:: end if hasBoolean then diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 49626665..dcfe83b2 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -103,6 +103,7 @@ function mt:_fastWardCasts(pos, topNode) end end end + self._index = self._index + 1 return topNode end diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 3e871499..3a24e5d0 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -3666,3 +3666,17 @@ TEST 'unknown' [[ ---@type _, number local <?x?>, y ]] + +TEST 'number[]' [[ +local t +---@cast t number[]? + +local x = t and <?t?>[i] +]] + +TEST 'number?' [[ +---@type number[]? +local t + +local <?x?> = t and t[i] +]] |