Skip to content

Add support for (either ...) in wast#8421

Merged
stevenfontanella merged 2 commits intomainfrom
either2
Mar 12, 2026
Merged

Add support for (either ...) in wast#8421
stevenfontanella merged 2 commits intomainfrom
either2

Conversation

@stevenfontanella
Copy link
Member

@stevenfontanella stevenfontanella commented Mar 5, 2026

  • Adds support for (either ...) in assert_return in WAST
  • Also allows customizing the error type in Result, which we use to keep track of the failing lane in assertions.

Example failure:

(module
  (func (export "f") (result i32)
    (i32.const 1)
  )
)

(assert_return (invoke "f") (either (i32.const 2) (i32.const 3)))
Expected one of (2 | 3) but got 1

Example failure with SIMD from relaxed_min_max.wast:

Expected one of (canonical f32 | canonical f32 | 0 | 0x00000000) at lane 0 but got i32x4 0x7fc00000 0x7fc00000 0x7fc00000 0x7fc00000

Part of #8261 and #8315. Fixes i16x8_relaxed_q15mulr_s.wast, i8x16_relaxed_swizzle.wast, relaxed_madd_nmadd.wast spec tests, and partially fixes relaxed_dot_product.wast, relaxed_laneselect.wast, relaxed_min_max.wast, and threads/thread.wast.

@stevenfontanella stevenfontanella force-pushed the either2 branch 4 times, most recently from c7fcea9 to d7c1324 Compare March 5, 2026 20:53
@stevenfontanella stevenfontanella changed the title [WIP] Add support for either in wast Add support for (either ...) in wast Mar 5, 2026
@stevenfontanella stevenfontanella marked this pull request as ready for review March 5, 2026 20:55
Comment on lines +382 to +383
if (!val.type.isRef() ||
!HeapType::isSubType(val.type.getHeapType(), ref->type)) {
Copy link
Member

Choose a reason for hiding this comment

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

We should probably check that the value is not null here, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was part of the existing code, I'll send a new PR for this with a test if that sounds good

Copy link
Member Author

Choose a reason for hiding this comment

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

Sent #8446 for this.

@stevenfontanella
Copy link
Member Author

Force-pushed to rebase onto #8434, should be good to go now.

@stevenfontanella stevenfontanella force-pushed the either2 branch 2 times, most recently from 876b215 to 02b81c7 Compare March 12, 2026 18:00
stevenfontanella added a commit that referenced this pull request Mar 12, 2026
For use in #8421. Previously LaneResults was only used if the expected
v128 constant contained NaN patterns, which meant that we lose the shape
information (otherwise they were stored/matched as a normal v128
Literal). Change the parser to always use LaneResult so that we keep the
shape information and can output exactly which lane doesn't match during
test failures.

Error message before:

```
expected i32x4 0x56485649 0x56485648 0x56485648 0x56485648, got i32x4 0x56485648 0x56485648 0x56485648 0x56485648
```

Error message after:

```
expected 22089, got 22088 at lane 0
```

Part of #8261 and #8315.
Base automatically changed from lanes to main March 12, 2026 18:31
@stevenfontanella stevenfontanella merged commit 3b6369e into main Mar 12, 2026
18 checks passed
@stevenfontanella stevenfontanella deleted the either2 branch March 12, 2026 22:31
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