Tsonnet #47: Compiler adds cycle detection for recursive function calls

Developer Hercules Lemke Merscher published the 47th entry in the Tsonnet series, a project building a Jsonnet compiler in OCaml. The update addresses a blind spot in the on-demand cycle detection introduced in the previous post, where recursive function calls could go undetected during translation. A new TranslatingFunction key was added to flag when a function body is mid-translation, allowing the compiler to raise an error if the same function is encountered again before completion. The fix covers both named functions and closures, handling direct and mutual recursion scenarios. A separate bug in collect_free_idents was also resolved to prevent a function's own name and parameter names from being incorrectly counted as free variables.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in