Unable to recursively call named lambda
smagnuso opened this issue · comments
smagnuso commented
function outer()
{
return function inner(x) {
if(x == 10)
return x;
return inner.call(x, x+1);
}(0);
}
console.log("Done: " + outer());
Any thoughts? I tried to implement it, but ended up butchering it :)
daurnimator commented
$ ../bin/castl.js --cat issue-22.lua
-- Lua code (Lua 5.2):
--------------------------------------------------------------------
local _ENV = require("castl.runtime");
local outer;
outer = (function (this)
do return (function (this, x)
if (_eq(x,10)) then
do return x; end
end
do return inner:call(x,(_addNum2(x,1))); end
end)(_ENV,0); end
end);
console:log((_addStr1("Done: ",outer(_ENV))));
--------------------------------------------------------------------
Looks like the anonymous function doesn't get named. i.e. this is a CASTL bug.