Closed catseye closed 12 years ago
Sorry for the delay in responding. It looks like this error was caused by a typo that closed the let binding before the rest of the code. Otherwise it should be functional now. Coincidentally this brought up another bug since the (exit 0) line should be returned by the resulting PHP but isn't.
For future reference, the issue for this new problem is at https://github.com/Scriptor/pharen/issues/36.
I found this while trying to play with
repl.phn
-- it doesn't actually loop (so I guess it's just aREP
, not aREPL
...) Looking at the generated code, the problem is evident: in the middle of thewhile
loop that was generated, the compiler also generated the linewhich breaks out of the loop.
Conceptually, if an expression is only being evaluated for its side-effects, it shouldn't try to
return
, at least not inside code that is subject to tail-call optimization. I'm not entirely sure of a good way to address this yet, but one idea would be to assign the result of evaluation to a local variable, and not generatereturn
until the end of the function (at which point you just return that local variable.)