Recursive types
Frityet opened this issue · 1 comments
Frityet commented
I want to type annotate a function that keeps returning functions until the argument is nil, the function is defined like this
local type ExecuteResult = function(): string
local type ExecuteArgument = ExecuteArgument | function(string): ExecuteResult
local function execute(prog: string): ExecuteArgument
local cmd = prog
local function f(arg: string | nil)
if arg is nil then
local f = io.popen(cmd)
local s = assert(f:read('*a'))
f:close()
return s
else
cmd = cmd .. " " .. arg
return f
end
end
return f
end
execute "echo" "hello" "world"()
This does not work because ExecuteArgument
becomes recursive, crashing teal. Is there any way around this?
svermeulen commented
Please try again since the codebase has since been mostly re-written