Scriptor/pharen — Issue #36: TCO'd loops not returning when inside let binding
Author: Scriptor
Created: 2011-12-22 01:11:30+00:00
State: open
Labels: Bug

The following function should result in a PHP function that will exit in the first iteration of the loop generated by tail-recursion optimization.

```clojure
(fn work ()
(let [foo "foo"]
(if (== foo "foo")
(foo)
(work)
```

However, the actual generated code is:

```php
function work(){
while(1){
$foo = "foo";
if(($foo == "foo")){
foo();
}
}
}
```

Where it calls `foo()` it should be `return foo()`.