@@ -1500,6 +1500,9 @@ Result<> IRBuilder::makeCallIndirect(Name table,
1500
1500
HeapType type,
1501
1501
bool isReturn,
1502
1502
std::optional<std::uint8_t > inline_) {
1503
+ if (!type.isSignature ()) {
1504
+ return Err{" expected function type annotation on call_indirect" };
1505
+ }
1503
1506
CallIndirect curr (wasm.allocator );
1504
1507
curr.heapType = type;
1505
1508
curr.operands .resize (type.getSignature ().params .size ());
@@ -2005,6 +2008,9 @@ Result<> IRBuilder::makeI31Get(bool signed_) {
2005
2008
Result<> IRBuilder::makeCallRef (HeapType type,
2006
2009
bool isReturn,
2007
2010
std::optional<std::uint8_t > inline_) {
2011
+ if (!type.isSignature ()) {
2012
+ return Err{" expected function type annotation on call_ref" };
2013
+ }
2008
2014
CallRef curr (wasm.allocator );
2009
2015
if (!type.isSignature ()) {
2010
2016
return Err{" expected function type" };
@@ -2217,6 +2223,9 @@ Result<> IRBuilder::makeBrOn(
2217
2223
}
2218
2224
2219
2225
Result<> IRBuilder::makeStructNew (HeapType type) {
2226
+ if (!type.isStruct ()) {
2227
+ return Err{" expected struct type annotation on struct.new" };
2228
+ }
2220
2229
StructNew curr (wasm.allocator );
2221
2230
curr.type = Type (type, NonNullable, Exact);
2222
2231
curr.operands .resize (type.getStruct ().fields .size ());
@@ -2248,6 +2257,9 @@ Result<> IRBuilder::makeStructGet(HeapType type,
2248
2257
2249
2258
Result<>
2250
2259
IRBuilder::makeStructSet (HeapType type, Index field, MemoryOrder order) {
2260
+ if (!type.isStruct ()) {
2261
+ return Err{" expected struct type annotation on struct.set" };
2262
+ }
2251
2263
StructSet curr;
2252
2264
curr.index = field;
2253
2265
CHECK_ERR (ChildPopper{*this }.visitStructSet (&curr, type));
@@ -2260,6 +2272,9 @@ Result<> IRBuilder::makeStructRMW(AtomicRMWOp op,
2260
2272
HeapType type,
2261
2273
Index field,
2262
2274
MemoryOrder order) {
2275
+ if (!type.isStruct ()) {
2276
+ return Err{" expected struct type annotation on struct.atomic.rmw" };
2277
+ }
2263
2278
StructRMW curr;
2264
2279
curr.index = field;
2265
2280
CHECK_ERR (ChildPopper{*this }.visitStructRMW (&curr, type));
@@ -2270,6 +2285,9 @@ Result<> IRBuilder::makeStructRMW(AtomicRMWOp op,
2270
2285
2271
2286
Result<>
2272
2287
IRBuilder::makeStructCmpxchg (HeapType type, Index field, MemoryOrder order) {
2288
+ if (!type.isStruct ()) {
2289
+ return Err{" expected struct type annotation on struct.atomic.rmw" };
2290
+ }
2273
2291
StructCmpxchg curr;
2274
2292
curr.index = field;
2275
2293
CHECK_ERR (ChildPopper{*this }.visitStructCmpxchg (&curr, type));
@@ -2280,6 +2298,9 @@ IRBuilder::makeStructCmpxchg(HeapType type, Index field, MemoryOrder order) {
2280
2298
}
2281
2299
2282
2300
Result<> IRBuilder::makeArrayNew (HeapType type) {
2301
+ if (!type.isArray ()) {
2302
+ return Err{" expected array type annotation on array.new" };
2303
+ }
2283
2304
ArrayNew curr;
2284
2305
curr.type = Type (type, NonNullable, Exact);
2285
2306
// Differentiate from array.new_default with dummy initializer.
@@ -2312,10 +2333,10 @@ Result<> IRBuilder::makeArrayNewElem(HeapType type, Name elem) {
2312
2333
}
2313
2334
2314
2335
Result<> IRBuilder::makeArrayNewFixed (HeapType type, uint32_t arity) {
2315
- ArrayNewFixed curr (wasm.allocator );
2316
2336
if (!type.isArray ()) {
2317
2337
return Err{" expected array type annotation on array.new_fixed" };
2318
2338
}
2339
+ ArrayNewFixed curr (wasm.allocator );
2319
2340
curr.type = Type (type, NonNullable);
2320
2341
curr.values .resize (arity);
2321
2342
CHECK_ERR (visitArrayNewFixed (&curr));
@@ -2334,6 +2355,9 @@ IRBuilder::makeArrayGet(HeapType type, bool signed_, MemoryOrder order) {
2334
2355
}
2335
2356
2336
2357
Result<> IRBuilder::makeArraySet (HeapType type, MemoryOrder order) {
2358
+ if (!type.isArray ()) {
2359
+ return Err{" expected array type annotation on array.set" };
2360
+ }
2337
2361
ArraySet curr;
2338
2362
CHECK_ERR (ChildPopper{*this }.visitArraySet (&curr, type));
2339
2363
CHECK_ERR (validateTypeAnnotation (type, curr.ref ));
@@ -2359,6 +2383,9 @@ Result<> IRBuilder::makeArrayCopy(HeapType destType, HeapType srcType) {
2359
2383
}
2360
2384
2361
2385
Result<> IRBuilder::makeArrayFill (HeapType type) {
2386
+ if (!type.isArray ()) {
2387
+ return Err{" expected array type annotation on array.fill" };
2388
+ }
2362
2389
ArrayFill curr;
2363
2390
CHECK_ERR (ChildPopper{*this }.visitArrayFill (&curr, type));
2364
2391
CHECK_ERR (validateTypeAnnotation (type, curr.ref ));
@@ -2396,6 +2423,9 @@ Result<> IRBuilder::makeArrayInitElem(HeapType type, Name elem) {
2396
2423
2397
2424
Result<>
2398
2425
IRBuilder::makeArrayRMW (AtomicRMWOp op, HeapType type, MemoryOrder order) {
2426
+ if (!type.isArray ()) {
2427
+ return Err{" expected array type annotation on array.atomic.rmw" };
2428
+ }
2399
2429
ArrayRMW curr;
2400
2430
CHECK_ERR (ChildPopper{*this }.visitArrayRMW (&curr, type));
2401
2431
CHECK_ERR (validateTypeAnnotation (type, curr.ref ));
@@ -2404,6 +2434,9 @@ IRBuilder::makeArrayRMW(AtomicRMWOp op, HeapType type, MemoryOrder order) {
2404
2434
}
2405
2435
2406
2436
Result<> IRBuilder::makeArrayCmpxchg (HeapType type, MemoryOrder order) {
2437
+ if (!type.isArray ()) {
2438
+ return Err{" expected array type annotation on array.atomic.rmw" };
2439
+ }
2407
2440
ArrayCmpxchg curr;
2408
2441
CHECK_ERR (ChildPopper{*this }.visitArrayCmpxchg (&curr, type));
2409
2442
CHECK_ERR (validateTypeAnnotation (type, curr.ref ));
@@ -2500,7 +2533,7 @@ Result<> IRBuilder::makeContNew(HeapType type) {
2500
2533
2501
2534
Result<> IRBuilder::makeContBind (HeapType sourceType, HeapType targetType) {
2502
2535
if (!sourceType.isContinuation () || !targetType.isContinuation ()) {
2503
- return Err{" expected continuation types " };
2536
+ return Err{" expected continuation type annotations on cont.bind " };
2504
2537
}
2505
2538
ContBind curr (wasm.allocator );
2506
2539
@@ -2590,7 +2623,7 @@ IRBuilder::makeResume(HeapType ct,
2590
2623
return Err{" the sizes of tags and labels must be equal" };
2591
2624
}
2592
2625
if (!ct.isContinuation ()) {
2593
- return Err{" expected continuation type" };
2626
+ return Err{" expected continuation type annotation on resume " };
2594
2627
}
2595
2628
2596
2629
Resume curr (wasm.allocator );
@@ -2623,7 +2656,7 @@ IRBuilder::makeResumeThrow(HeapType ct,
2623
2656
return Err{" the sizes of tags and labels must be equal" };
2624
2657
}
2625
2658
if (!ct.isContinuation ()) {
2626
- return Err{" expected continuation type" };
2659
+ return Err{" expected continuation type annotation on resume_throw " };
2627
2660
}
2628
2661
2629
2662
ResumeThrow curr (wasm.allocator );
@@ -2649,7 +2682,7 @@ IRBuilder::makeResumeThrow(HeapType ct,
2649
2682
2650
2683
Result<> IRBuilder::makeStackSwitch (HeapType ct, Name tag) {
2651
2684
if (!ct.isContinuation ()) {
2652
- return Err{" expected continuation type" };
2685
+ return Err{" expected continuation type annotation on switch " };
2653
2686
}
2654
2687
StackSwitch curr (wasm.allocator );
2655
2688
curr.tag = tag;
0 commit comments