Skip to content

Commit d97a214

Browse files
committed
fix
1 parent 943ba62 commit d97a214

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

script/vm/compiler.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ local function compileLocal(source)
887887

888888
-- for x = ... do
889889
if source.parent.type == 'loop' then
890-
vm.setNode(source, globalMgr.getGlobal('type', 'integer'))
890+
vm.compileNode(source.parent)
891891
end
892892

893893
if source.bindDocs then
@@ -1246,6 +1246,12 @@ local compilerSwitch = util.switch()
12461246
end
12471247
end
12481248
end)
1249+
: case 'loop'
1250+
: call(function (source)
1251+
if source.loc then
1252+
vm.setNode(source.loc, globalMgr.getGlobal('type', 'integer'))
1253+
end
1254+
end)
12491255
: case 'doc.type'
12501256
: call(function (source)
12511257
for _, typeUnit in ipairs(source.types) do

test/type_inference/init.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,3 +2121,9 @@ local x
21212121
---@type integer
21222122
<?x?> = XXX
21232123
]]
2124+
2125+
TEST 'unknown' [[
2126+
for _ = 1, 999 do
2127+
local <?x?>
2128+
end
2129+
]]

0 commit comments

Comments
 (0)