Skip to content

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 11, 2026

In processResumeHandlers (src/ir/subtype-exprs.h), the inner loop uses the outer loop variable i instead of j to index into tagSig.params and expected:

for (Index i = 0; i < handlerTags.size(); ++i) {
  // ...
  for (Index j = 0; j < tagSig.params.size(); ++j) {
    self()->noteSubtype(tagSig.params[i], expected[i]); // should be [j]
  }

This produces wrong subtyping constraints for resume handlers whose tags have multiple parameters. It also causes out-of-bounds access when the handler index i is >= the tag's parameter count.

Fix: [i] -> [j] (one-character change).

Test: added a case with two handlers — one single-param tag and one two-param tag — and verified the correct (Type, Type) pairs are noted.

The inner loop in processResumeHandlers used the outer loop variable `i`
instead of `j` to index into tagSig.params and expected. This caused
wrong subtyping constraints for resume handlers with multi-parameter
tags, and potential out-of-bounds access when the handler index exceeds
the tag's parameter count.
@sumleo sumleo force-pushed the fix-resume-handlers-loop-var branch from 4c0e123 to a3ee6cb Compare February 11, 2026 01:46
@sumleo sumleo requested a review from tlively February 11, 2026 01:52
Copy link
Member

@tlively tlively left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@tlively tlively merged commit 07bf6f7 into WebAssembly:main Feb 11, 2026
17 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