Repository navigation
Conversation
We catch any panics in `Runner::run_once`, and turn them into `Err` results. This prevents them from affecting the extraction of other files.
Also updates the remaining tests to use the new infallible interface.
When `panic!` gets called, the default Rust panic handler prints out the error (and possibly a backtrace) to stderr. This means even if we handle the panics in `run_once`, we still get the printed output. To avoid this, we use `resume_unwind` (which foregoes the default behaviour) instead, and add a helper function called `translation_failure` that takes care of the places where translation could previously panic.
tausbn
force-pushed
the
tausbn/yeast-isolate-interpolation-contexts
branch
2 times, most recently
from
November 6, 2026 15:12
fdd6839 to
027df4b
Compare
Wraps each interpolation is a small bit of code that clones the user context before running the block of code, and restores it afterwards. We only do this for blocks that actually mention the `ctx` variable. Other cases (the vast majority) just inline the block directly, so that there's no unnecessary overhead in the most common case. The `ctx` check is not perfect -- it won't notice cases where you (outside the interpolation) rebind it to a different variable, say, but it should be a good enough test for the way we currently write rules.
This allows us to get rid of two uses of `ctx.scoped`, cleaning up the code a bit in the process.
tausbn
force-pushed
the
tausbn/yeast-isolate-interpolation-contexts
branch
from
November 6, 2026 15:19
027df4b to
81057bd
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Interpolation handling can fail to compile with borrowed builders and leak context mutations across translations, while public query failures can lose readable diagnostics.
6 open issues
Restore interpolations through user_ctx for borrowed builders · New Restore context when interpolation exits early · New Detect context mutations hidden in closures and macros · New Preserve readable errors from public do_match calls · New Preserve borrowed inputs during interpolation evaluation Preserve BuildCtx borrowing and assignment behavior in interpolations
Review effort: Max
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Currently we have context isolation between rules: a change to
ctxis visible when we translate child nodes (if the translation happens after the change, of course), but these changes cannot leak to different rules.However, the same isolation does not apply to context modifications made inside of the interpolations of an output template. That is, in the following template
both
barandbazwill be evaluated in a reset context. If we swap the two field assignments, then onlybargets a reset context.This behaviour is very surprising, and likely to cause hard-to-spot bugs.
To fix this, we now clone the user context for each interpolation individually (but only if they refer to the
ctxvariable), which means they cannot interfere with each other. This is slightly less efficient, but much safer.This also enables us to get rid of the two uses of
ctx.scopedthat we currently have, and clean up the code a bit.