Fix unreachable br_on_cast parse bug - #8948
Open
tlively wants to merge 1 commit into
Open
Conversation
The br_on_cast* family of instructions take input and output type immediates. We do not store the input type in the IR, so IRBuilder has to check the type of the `ref` operand against the input type before the input type is lost. For br_on_cast_desc_eq{_fail} instructions with unreachable descriptor operands, we had a bug that would allow us to pop a `ref` operand with an incorrect type, which would then immediately fail that type check. This was incorrect because the unreachable `desc` operand should have created a polymorphic stack that allowed popping any valid type. Fix the bug by threading the expected input type through IRBuilder to ChildTyper, where we can note the proper type constraint on the `ref` operand.
tlively
requested review from
aheejin and
kripken
and removed request for
a team
July 29, 2026 01:05
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.
The br_on_cast* family of instructions take input and output type immediates. We do not store the input type in the IR, so IRBuilder has to check the type of the
refoperand against the input type before the input type is lost. For br_on_cast_desc_eq{_fail} instructions with unreachable descriptor operands, we had a bug that would allow us to pop arefoperand with an incorrect type, which would then immediately fail that type check. This was incorrect because the unreachabledescoperand should have created a polymorphic stack that allowed popping any valid type. Fix the bug by threading the expected input type through IRBuilder to ChildTyper, where we can note the proper type constraint on therefoperand.