Skip to content

Commit 5816d69

Browse files
authored
Fix parsing error on array.new_fixed on non-array (#7604)
Fixes #7602
1 parent 6431a07 commit 5816d69

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/wasm/wasm-ir-builder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2213,6 +2213,9 @@ Result<> IRBuilder::makeArrayNewElem(HeapType type, Name elem) {
22132213

22142214
Result<> IRBuilder::makeArrayNewFixed(HeapType type, uint32_t arity) {
22152215
ArrayNewFixed curr(wasm.allocator);
2216+
if (!type.isArray()) {
2217+
return Err{"expected array type annotation on array.new_fixed"};
2218+
}
22162219
curr.type = Type(type, NonNullable);
22172220
curr.values.resize(arity);
22182221
CHECK_ERR(visitArrayNewFixed(&curr));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
;; RUN: not wasm-opt -all %s 2>&1 | filecheck %s
2+
3+
;; CHECK: expected array type annotation on array.new_fixed
4+
5+
(module
6+
(type $struct (struct (field anyref)))
7+
8+
;; The type here is a struct, not an array, so we error.
9+
(global $struct (ref $struct) (array.new_fixed $struct 1
10+
(i32.const 64)
11+
))
12+
)

0 commit comments

Comments
 (0)