Skip to content

Fix unreachable br_on_cast parse bug - #8948

Open
tlively wants to merge 1 commit into
mainfrom
fix-8935-parse-bug
Open

Fix unreachable br_on_cast parse bug#8948
tlively wants to merge 1 commit into
mainfrom
fix-8935-parse-bug

Conversation

@tlively

@tlively tlively commented Jul 29, 2026

Copy link
Copy Markdown
Member

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.

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
tlively requested a review from a team as a code owner July 29, 2026 01:05
@tlively
tlively requested review from aheejin and kripken and removed request for a team July 29, 2026 01:05
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.

1 participant