tl icon indicating copy to clipboard operation
tl copied to clipboard

Feature request: support usage before declaration for method

Open BLKTower opened this issue 1 year ago • 1 comments

Giving:

local record mod
end

function mod:foo1()
    self:foo2() -- error: invalid key 'foo2'
end

function mod:foo2()
end

It'd be nice that teal can support usage before declaration for method. Desired behavior: No error

BLKTower avatar Dec 28 '24 00:12 BLKTower

I just thought I'd note that the following (explicitly declaring the method type before assigning the method itself) does work:

local record mod
    foo2: function(self)
end

function mod:foo1()
    self:foo2() -- no longer errors, as foo2 has been forward declared
end

function mod:foo2()
end

JR-Mitchell avatar Jan 01 '25 18:01 JR-Mitchell