teal-language / tl

The compiler for Teal, a typed dialect of Lua
MIT License
2.11k stars 109 forks source link

incorrect "outside of the scope declaration" analysis #517

Closed virusdefender closed 2 years ago

virusdefender commented 2 years ago
local record M
    record daemon_plugin
        start: function(self: M.daemon_plugin, config: any)
        stop: function(self: M.daemon_plugin)
    end
end

local b : M.daemon_plugin = {}

-- cannot add undeclared function 'start' outside of the scope where 'b' was originally declared
function b:start(config: any)
end

-- works
function b.start(self: M.daemon_plugin, config: any)
end

-- works
function b:stop()
end

-- works
function b.stop(self: M.daemon_plugin)
end

if the function has no more arguments, there is no error message

hishamhm commented 2 years ago

@virusdefender Thank you for the report and test case! It's now fixed in master.