Skip to content

Commit 75b8b11

Browse files
committed
special treat local x; x = function() end
1 parent 599b447 commit 75b8b11

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

script/vm/compiler.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,17 @@ local function compileLocal(source)
10081008
vm.setNode(source, vm.compileNode(source.value))
10091009
end
10101010
end
1011+
if not hasMarkValue and not hasMarkValue then
1012+
if source.ref then
1013+
for _, ref in ipairs(source.ref) do
1014+
if ref.type == 'setlocal'
1015+
and ref.value
1016+
and ref.value.type == 'function' then
1017+
vm.setNode(source, vm.compileNode(ref.value))
1018+
end
1019+
end
1020+
end
1021+
end
10111022
-- function x.y(self, ...) --> function x:y(...)
10121023
if source[1] == 'self'
10131024
and not hasMarkDoc

test/type_inference/init.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3167,3 +3167,11 @@ TEST 'number' [[
31673167
local function f() end
31683168
local x, y, <?z?> = 1, 2, f()
31693169
]]
3170+
3171+
TEST 'function' [[
3172+
local f
3173+
3174+
print(<?f?>)
3175+
3176+
function f() end
3177+
]]

0 commit comments

Comments
 (0)