Skip to content

wit-parser: return errors instead of panicking when decoding - #2850

Merged
alexcrichton merged 2 commits into
bytecodealliance:mainfrom
sansmoraxz:wit-decode/bail-1-panics
Nov 24, 2026
Merged

alexcrichton merged 2 commits into
bytecodealliance:mainfrom
sansmoraxz:wit-decode/bail-1-panics

Conversation

@sansmoraxz

Copy link
Copy Markdown
Contributor

This switches the decoder's panic points to errors

Decoding a component or a WIT package had `assert!`s, `unwrap()`s,
`unreachable!()`s and map indexing that panic if what they expect
doesn't hold. These are expected to be upheld by validation, but they
depend on the input, so report them as errors rather than panicking.
The WIT printer panicked on a `Resolve` decoded from a component where
an unnamed instance uses a type from another unnamed instance, as there's
no name to print the `use` with. Such a `Resolve` still encodes, so
decoding keeps accepting it, and printing now returns an error instead.
@sansmoraxz
sansmoraxz requested a review from a team as a code owner November 24, 2026 16:45
@sansmoraxz
sansmoraxz requested review from pchickey and removed request for a team November 24, 2026 16:45
@alexcrichton
alexcrichton added this pull request to the merge queue Nov 24, 2026
Merged via the queue into bytecodealliance:main with commit f6f0244 Nov 24, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants