Proper Tail Optimization doesn't work

Author: amiroucheCreated Sep 2, 2017Updated Jan 5, 2025

GNU Guile has now a working prototype of a compiler backend that generates JavaScript.

It use lots of tail calls. I compiled it with traceur using the following command:

bash
$ traceur --out script.js --script out.prettier.js --proper-tail-calls  --experimental

I run it in chrome using the following html file:

xml
<html>
  <body>
    <script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
    <script src="https://google.github.io/traceur-compiler/bin/BrowserSystem.js"></script>
    <script src="/script.js" type="text/javascript"></script>
  </body>
</html>

It fails with a Uncaught RangeError: Maximum call stack size exceeded.

The original scheme program is:

scheme
(js-invoke (js-eval "console") "log" "héllo world")

The input JavaScript file can be found here. That input file is correctly intrepreted by nodejs v8.4.0 using the --harmony_tailcalls flag.