Skip to content

yeast: Catch translation panics - #23035

Open
tausbn wants to merge 4 commits into
mainfrom
tausbn/yeast-catch-translation-panics
Open

tausbn wants to merge 4 commits into
mainfrom
tausbn/yeast-catch-translation-panics

Conversation

@tausbn

@tausbn tausbn commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Adds a catcher for all panics that occur inside the desugaring runner. This prevents the panics from bubbling up to the top level and panicking the entire extraction. Instead, any panic just results in the file in question not being extracted.

With this handler in place, we can get rid of the use of Result in translations, for which the Err variant was only used for unrecoverable errors anyway (which would then bubble up to the top of the runner and cause extraction for that file to fail). This makes the code a lot cleaner.


Can be reviewed commit-by-commit. A DCA run has been started.

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.
@tausbn tausbn added the no-change-note-required This PR does not need a change note label Nov 5, 2026
@tausbn
tausbn requested a max review from Copilot November 5, 2026 22:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Caught translation failures skip files without structured diagnostics, hiding missing analysis coverage, while the default panic hook emits stderr output outside tracing controls.

2 open issues
What changed in this PR

This PR isolates YEAST translation panics so a failing file can be skipped without terminating extraction. It also simplifies the translation APIs used by Swift desugaring.

Changes:

  • Catch translation panics in the runner and return their messages as errors.
  • Remove Result propagation from translation APIs, macros, and Swift rules.
  • Update existing tests and add regression coverage for panic recovery.
File Description
unified/​extractor/​src/​languages/​swift/​swift.rs Adapt Swift rules to direct translation returns.
shared/​yeast/​tests/​test.rs Update API usage and test caught translation panics.
shared/​yeast/​src/​query.rs Return match booleans directly.
shared/​yeast/​src/​lib.rs Catch runner panics and simplify translation interfaces.
shared/​yeast/​src/​captures.rs Remove fallible capture-translation plumbing.
shared/​yeast/​src/​build.rs Simplify recursive translation and remove deferred errors.
shared/​yeast-macros/​src/​lower.rs Generate guards and transforms without Result wrappers.

Review effort: Max

Comment thread shared/yeast/src/lib.rs Resolved
Comment thread shared/yeast/src/lib.rs Resolved
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
tausbn marked this pull request as ready for review November 6, 2026 13:06
@tausbn
tausbn requested a review from a team as a code owner November 6, 2026 13:06

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants