Sema: handle foo() catch |err| switch (err) {...} for !noreturn - #25203
Open
JackoCoolio wants to merge 3 commits into
Open
JackoCoolio wants to merge 3 commits into
JackoCoolio wants to merge 3 commits into
Conversation
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.
Fixes #25037. The issue there is that when analyzing a
switch_block_err_union, we analyze the non-error case which includes anerr_union_payload_unsafeinstruction.zirErrUnionPayloadsees that the OPV of the payload isunreachable, so it returns that without emitting any AIR. The assertion at the bottom ofanalyzeBodyInnerthen fails becauseblock.instructions.items.len == 0:https://github.com/ziglang/zig/blob/0b75a2a1b1972777350c33c27cfe720172491de6/src/Sema.zig#L1979C9-L1984C10
My fix was just not analyzing the non-error case (by not bothering with the
cond_bronis_non_err) when the payload type isnoreturn.Just skipping the assertions above when
air_inst == .unreachable_valuealso seemed to work fine, but didn't feel great. Same for adding asema.analyzeUnreachable(...)inzirErrUnionPayload.I also replaced
std.ArrayListUnmanagedwithstd.ArrayListthroughout Sema.