Skip to content

Commit c555e12

Browse files
Reject null in (assert_return ... (ref.<non null>)) (#8446)
The added test would previously pass wrongly.
1 parent 3b6369e commit c555e12

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/tools/wasm-shell.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ struct Shell {
368368
}
369369
} else if (auto* ref = std::get_if<RefResult>(&expected)) {
370370
if (!val.type.isRef() ||
371-
!HeapType::isSubType(val.type.getHeapType(), ref->type)) {
371+
!HeapType::isSubType(val.type.getHeapType(), ref->type) ||
372+
val.isNull()) {
372373
err << ref->type;
373374
return AlternativeErr{err.str()};
374375
}

test/lit/basic/ref.wast

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
;; RUN: not wasm-shell %s 2>&1 | filecheck %s
2+
3+
(module
4+
(func (export "f") (result (ref null i31))
5+
(ref.null i31)
6+
)
7+
)
8+
9+
;; CHECK: expected i31, got nullref
10+
(assert_return (invoke "f") (ref.i31))

0 commit comments

Comments
 (0)