Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces tail-call optimization support for tailstrict function calls and makes materialization iterative to avoid JVM stack overflows, with accompanying tests and updated error stack expectations.
Changes:
- Add a
TailCallsentinel +TailstrictModeprotocol and integrate a trampoline (TailCall.resolve) into function application paths. - Rewrite
Materializer.apply0to use an explicit stack (iterative traversal) and addSettings.maxMaterializeDepthas a safety bound. - Add comprehensive
tailstrict/Materializer integration tests and update the expected stack trace golden output.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sjsonnet/test/src/sjsonnet/TailCallOptimizationTests.scala | New test suite covering tailstrict semantics, deep recursion, and Materializer integration (no TailCall leakage). |
| sjsonnet/test/resources/test_suite/error.tailstrict_stack.jsonnet.golden | Updates expected stack trace frame labeling after TCO changes. |
| sjsonnet/src/sjsonnet/Val.scala | Implements TailCall, TailCall.resolve, TailstrictMode, and resolves TailCalls at function-application boundaries. |
| sjsonnet/src/sjsonnet/Settings.scala | Adds maxMaterializeDepth setting used by the new iterative materializer. |
| sjsonnet/src/sjsonnet/Materializer.scala | Replaces recursive materialization with an iterative, stack-based algorithm + defensive TailCall leakage check. |
| sjsonnet/src/sjsonnet/Expr.scala | Adds TailstrictableExpr marker trait used by the evaluator’s tail-call support. |
| sjsonnet/src/sjsonnet/Evaluator.scala | Integrates TailCall trampoline wrapping for tailstrict calls and adds tail-position evaluation support. |
| sjsonnet/src/sjsonnet/Error.scala | Refactors frame addition to allow adding frames by exprErrorString (addFrameString). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d57e5e0 to
5dd9b27
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Motivation:
Add partial TCO.
refs:CertainLach/jrsonnet#121
can work now and evaluate to
truebut was:on main
current:
Another case is :