...
1;; Failures in unreachable code.
2
3(assert_invalid
4 (module (func $local-index (unreachable) (drop (local.get 0))))
5 "unknown local"
6)
7(assert_invalid
8 (module (func $global-index (unreachable) (drop (global.get 0))))
9 "unknown global"
10)
11(assert_invalid
12 (module (func $func-index (unreachable) (call 1)))
13 "unknown function"
14)
15(assert_invalid
16 (module (func $label-index (unreachable) (br 1)))
17 "unknown label"
18)
19
20(assert_invalid
21 (module (func $type-num-vs-num
22 (unreachable) (drop (i64.eqz (i32.const 0))))
23 )
24 "type mismatch"
25)
26(assert_invalid
27 (module (func $type-poly-num-vs-num (result i32)
28 (unreachable) (i64.const 0) (i32.const 0) (select)
29 ))
30 "type mismatch"
31)
32(assert_invalid
33 (module (func $type-poly-transitive-num-vs-num (result i32)
34 (unreachable)
35 (i64.const 0) (i32.const 0) (select)
36 (i32.const 0) (i32.const 0) (select)
37 ))
38 "type mismatch"
39)
40
41(assert_invalid
42 (module (func $type-unconsumed-const (unreachable) (i32.const 0)))
43 "type mismatch"
44)
45(assert_invalid
46 (module (func $type-unconsumed-result (unreachable) (i32.eqz)))
47 "type mismatch"
48)
49(assert_invalid
50 (module (func $type-unconsumed-result2
51 (unreachable) (i32.const 0) (i32.add)
52 ))
53 "type mismatch"
54)
55(assert_invalid
56 (module (func $type-unconsumed-poly0 (unreachable) (select)))
57 "type mismatch"
58)
59(assert_invalid
60 (module (func $type-unconsumed-poly1 (unreachable) (i32.const 0) (select)))
61 "type mismatch"
62)
63(assert_invalid
64 (module (func $type-unconsumed-poly2
65 (unreachable) (i32.const 0) (i32.const 0) (select)
66 ))
67 "type mismatch"
68)
69
70(assert_invalid
71 (module (func $type-unary-num-vs-void-after-break
72 (block (br 0) (block (drop (i32.eqz (nop)))))
73 ))
74 "type mismatch"
75)
76(assert_invalid
77 (module (func $type-unary-num-vs-num-after-break
78 (block (br 0) (drop (i32.eqz (f32.const 1))))
79 ))
80 "type mismatch"
81)
82(assert_invalid
83 (module (func $type-binary-num-vs-void-after-break
84 (block (br 0) (block (drop (f32.eq (i32.const 1)))))
85 ))
86 "type mismatch"
87)
88(assert_invalid
89 (module (func $type-binary-num-vs-num-after-break
90 (block (br 0) (drop (f32.eq (i32.const 1) (f32.const 0))))
91 ))
92 "type mismatch"
93)
94(assert_invalid
95 (module (func $type-block-value-num-vs-void-after-break
96 (block (br 0) (i32.const 1))
97 ))
98 "type mismatch"
99)
100(assert_invalid
101 (module (func $type-block-value-num-vs-num-after-break (result i32)
102 (block (result i32) (i32.const 1) (br 0) (f32.const 0))
103 ))
104 "type mismatch"
105)
106(assert_invalid
107 (module (func $type-loop-value-num-vs-void-after-break
108 (block (loop (br 1) (i32.const 1)))
109 ))
110 "type mismatch"
111)
112(assert_invalid
113 (module (func $type-loop-value-num-vs-num-after-break (result i32)
114 (loop (result i32) (br 1 (i32.const 1)) (f32.const 0))
115 ))
116 "type mismatch"
117)
118(assert_invalid
119 (module (func $type-func-value-num-vs-void-after-break
120 (br 0) (i32.const 1)
121 ))
122 "type mismatch"
123)
124(assert_invalid
125 (module (func $type-func-value-num-vs-num-after-break (result i32)
126 (br 0 (i32.const 1)) (f32.const 0)
127 ))
128 "type mismatch"
129)
130
131(assert_invalid
132 (module (func $type-unary-num-vs-void-after-return
133 (return) (block (drop (i32.eqz (nop))))
134 ))
135 "type mismatch"
136)
137(assert_invalid
138 (module (func $type-unary-num-vs-num-after-return
139 (return) (drop (i32.eqz (f32.const 1)))
140 ))
141 "type mismatch"
142)
143(assert_invalid
144 (module (func $type-binary-num-vs-void-after-return
145 (return) (block (drop (f32.eq (i32.const 1))))
146 ))
147 "type mismatch"
148)
149(assert_invalid
150 (module (func $type-binary-num-vs-num-after-return
151 (return) (drop (f32.eq (i32.const 1) (f32.const 0)))
152 ))
153 "type mismatch"
154)
155(assert_invalid
156 (module (func $type-block-value-num-vs-void-after-return
157 (block (return) (i32.const 1))
158 ))
159 "type mismatch"
160)
161(assert_invalid
162 (module (func $type-block-value-num-vs-num-after-return (result i32)
163 (block (result i32) (i32.const 1) (return (i32.const 0)) (f32.const 0))
164 ))
165 "type mismatch"
166)
167(assert_invalid
168 (module (func $type-loop-value-num-vs-void-after-return
169 (block (loop (return) (i32.const 1)))
170 ))
171 "type mismatch"
172)
173(assert_invalid
174 (module (func $type-loop-value-num-vs-num-after-return (result i32)
175 (loop (result i32) (return (i32.const 1)) (f32.const 0))
176 ))
177 "type mismatch"
178)
179(assert_invalid
180 (module (func $type-func-value-num-vs-void-after-return
181 (return) (i32.const 1)
182 ))
183 "type mismatch"
184)
185(assert_invalid
186 (module (func $type-func-value-num-vs-num-after-return (result i32)
187 (return (i32.const 1)) (f32.const 0)
188 ))
189 "type mismatch"
190)
191
192(assert_invalid
193 (module (func $type-unary-num-vs-void-after-unreachable
194 (unreachable) (block (drop (i32.eqz (nop))))
195 ))
196 "type mismatch"
197)
198(assert_invalid
199 (module (func $type-unary-num-vs-void-in-loop-after-unreachable
200 (unreachable) (loop (drop (i32.eqz (nop))))
201 ))
202 "type mismatch"
203)
204(assert_invalid
205 (module (func $type-unary-num-vs-void-in-i32-loop-after-unreachable
206 (unreachable) (loop (result i32) (i32.eqz (nop)))
207 ))
208 "type mismatch"
209)
210(assert_invalid
211 (module (func $type-unary-num-vs-num-after-unreachable
212 (unreachable) (drop (i32.eqz (f32.const 1)))
213 ))
214 "type mismatch"
215)
216(assert_invalid
217 (module (func $type-binary-num-vs-void-after-unreachable
218 (unreachable) (block (drop (f32.eq (i32.const 1))))
219 ))
220 "type mismatch"
221)
222(assert_invalid
223 (module (func $type-binary-num-vs-num-after-unreachable
224 (unreachable) (drop (f32.eq (i32.const 1) (f32.const 0)))
225 ))
226 "type mismatch"
227)
228(assert_invalid
229 (module (func $type-block-value-num-vs-void-after-unreachable
230 (block (unreachable) (i32.const 1))
231 ))
232 "type mismatch"
233)
234(assert_invalid
235 (module (func $type-block-value-num-vs-num-after-unreachable (result i32)
236 (block (result i32) (i32.const 1) (unreachable) (f32.const 0))
237 ))
238 "type mismatch"
239)
240(assert_invalid
241 (module (func $type-loop-value-num-vs-void-after-unreachable
242 (block (loop (unreachable) (i32.const 1)))
243 ))
244 "type mismatch"
245)
246(assert_invalid
247 (module (func $type-loop-value-num-vs-num-after-unreachable (result i32)
248 (loop (result i32) (unreachable) (f32.const 0))
249 ))
250 "type mismatch"
251)
252(assert_invalid
253 (module (func $type-func-value-num-vs-void-after-unreachable
254 (unreachable) (i32.const 1)
255 ))
256 "type mismatch"
257)
258(assert_invalid
259 (module (func $type-func-value-num-vs-num-after-unreachable (result i32)
260 (unreachable) (f32.const 0)
261 ))
262 "type mismatch"
263)
264(assert_invalid
265 (module (func $type-unary-num-vs-void-in-if-after-unreachable
266 (unreachable) (if (i32.const 0) (then (drop (i32.eqz (nop)))))
267 ))
268 "type mismatch"
269)
270(assert_invalid
271 (module (func $type-unary-num-vs-void-in-else-after-unreachable
272 (unreachable) (if (i32.const 0) (then (nop)) (else (drop (i32.eqz (nop)))))
273 ))
274 "type mismatch"
275)
276(assert_invalid
277 (module (func $type-unary-num-vs-void-in-else-after-unreachable-if
278 (if (i32.const 0) (then (unreachable)) (else (drop (i32.eqz (nop)))))
279 ))
280 "type mismatch"
281)
282
283(assert_invalid
284 (module (func $type-unary-num-vs-void-after-nested-unreachable
285 (block (unreachable)) (block (drop (i32.eqz (nop))))
286 ))
287 "type mismatch"
288)
289(assert_invalid
290 (module (func $type-unary-num-vs-num-after-nested-unreachable
291 (block (unreachable)) (drop (i32.eqz (f32.const 1)))
292 ))
293 "type mismatch"
294)
295(assert_invalid
296 (module (func $type-binary-num-vs-void-after-nested-unreachable
297 (block (unreachable)) (block (drop (f32.eq (i32.const 1))))
298 ))
299 "type mismatch"
300)
301(assert_invalid
302 (module (func $type-binary-num-vs-num-after-nested-unreachable
303 (block (unreachable)) (drop (f32.eq (i32.const 1) (f32.const 0)))
304 ))
305 "type mismatch"
306)
307(assert_invalid
308 (module (func $type-block-value-num-vs-void-after-nested-unreachable
309 (block (block (unreachable)) (i32.const 1))
310 ))
311 "type mismatch"
312)
313(assert_invalid
314 (module (func $type-block-value-num-vs-num-after-nested-unreachable
315 (result i32)
316 (block (result i32) (i32.const 1) (block (unreachable)) (f32.const 0))
317 ))
318 "type mismatch"
319)
320(assert_invalid
321 (module (func $type-loop-value-num-vs-void-after-nested-unreachable
322 (block (loop (block (unreachable)) (i32.const 1)))
323 ))
324 "type mismatch"
325)
326(assert_invalid
327 (module (func $type-loop-value-num-vs-num-after-nested-unreachable
328 (result i32)
329 (loop (result i32) (block (unreachable)) (f32.const 0))
330 ))
331 "type mismatch"
332)
333(assert_invalid
334 (module (func $type-func-value-num-vs-void-after-nested-unreachable
335 (block (unreachable)) (i32.const 1)
336 ))
337 "type mismatch"
338)
339(assert_invalid
340 (module (func $type-func-value-num-vs-num-after-nested-unreachable
341 (result i32)
342 (block (unreachable)) (f32.const 0)
343 ))
344 "type mismatch"
345)
346
347(assert_invalid
348 (module (func $type-unary-num-vs-void-after-infinite-loop
349 (loop (br 0)) (block (drop (i32.eqz (nop))))
350 ))
351 "type mismatch"
352)
353(assert_invalid
354 (module (func $type-unary-num-vs-num-after-infinite-loop
355 (loop (br 0)) (drop (i32.eqz (f32.const 1)))
356 ))
357 "type mismatch"
358)
359(assert_invalid
360 (module (func $type-binary-num-vs-void-after-infinite-loop
361 (loop (br 0)) (block (drop (f32.eq (i32.const 1))))
362 ))
363 "type mismatch"
364)
365(assert_invalid
366 (module (func $type-binary-num-vs-num-after-infinite-loop
367 (loop (br 0)) (drop (f32.eq (i32.const 1) (f32.const 0)))
368 ))
369 "type mismatch"
370)
371(assert_invalid
372 (module (func $type-block-value-num-vs-void-after-infinite-loop
373 (block (loop (br 0)) (i32.const 1))
374 ))
375 "type mismatch"
376)
377(assert_invalid
378 (module (func $type-block-value-num-vs-num-after-infinite-loop (result i32)
379 (block (result i32) (i32.const 1) (loop (br 0)) (f32.const 0))
380 ))
381 "type mismatch"
382)
383(assert_invalid
384 (module (func $type-loop-value-num-vs-void-after-infinite-loop
385 (block (loop (loop (br 0)) (i32.const 1)))
386 ))
387 "type mismatch"
388)
389(assert_invalid
390 (module (func $type-loop-value-num-vs-num-after-infinite-loop (result i32)
391 (loop (result i32) (loop (br 0)) (f32.const 0))
392 ))
393 "type mismatch"
394)
395(assert_invalid
396 (module (func $type-func-value-num-vs-void-after-infinite-loop
397 (loop (br 0)) (i32.const 1)
398 ))
399 "type mismatch"
400)
401(assert_invalid
402 (module (func $type-func-value-num-vs-num-after-infinite-loop (result i32)
403 (loop (br 0)) (f32.const 0)
404 ))
405 "type mismatch"
406)
407
408(assert_invalid
409 (module (func $type-unary-num-vs-void-in-dead-body
410 (if (i32.const 0) (then (drop (i32.eqz (nop)))))
411 ))
412 "type mismatch"
413)
414(assert_invalid
415 (module (func $type-unary-num-vs-num-in-dead-body
416 (if (i32.const 0) (then (drop (i32.eqz (f32.const 1)))))
417 ))
418 "type mismatch"
419)
420(assert_invalid
421 (module (func $type-binary-num-vs-void-in-dead-body
422 (if (i32.const 0) (then (drop (f32.eq (i32.const 1)))))
423 ))
424 "type mismatch"
425)
426(assert_invalid
427 (module (func $type-binary-num-vs-num-in-dead-body
428 (if (i32.const 0) (then (drop (f32.eq (i32.const 1) (f32.const 0)))))
429 ))
430 "type mismatch"
431)
432(assert_invalid
433 (module (func $type-if-value-num-vs-void-in-dead-body
434 (if (i32.const 0) (then (i32.const 1)))
435 ))
436 "type mismatch"
437)
438(assert_invalid
439 (module (func $type-if-value-num-vs-num-in-dead-body (result i32)
440 (if (result i32) (i32.const 0) (then (f32.const 0)))
441 ))
442 "type mismatch"
443)
444(assert_invalid
445 (module (func $type-block-value-num-vs-void-in-dead-body
446 (if (i32.const 0) (then (block (i32.const 1))))
447 ))
448 "type mismatch"
449)
450(assert_invalid
451 (module (func $type-block-value-num-vs-num-in-dead-body (result i32)
452 (if (result i32) (i32.const 0) (then (block (result i32) (f32.const 0))))
453 ))
454 "type mismatch"
455)
456(assert_invalid
457 (module (func $type-block-value-num-vs-void-in-dead-body
458 (if (i32.const 0) (then (loop (i32.const 1))))
459 ))
460 "type mismatch"
461)
462(assert_invalid
463 (module (func $type-block-value-num-vs-num-in-dead-body (result i32)
464 (if (result i32) (i32.const 0) (then (loop (result i32) (f32.const 0))))
465 ))
466 "type mismatch"
467)
468
469(assert_invalid
470 (module (func $type-return-second-num-vs-num (result i32)
471 (return (i32.const 1)) (return (f64.const 1))
472 ))
473 "type mismatch"
474)
475
476(assert_invalid
477 (module (func $type-br-second-num-vs-num (result i32)
478 (block (result i32) (br 0 (i32.const 1)) (br 0 (f64.const 1)))
479 ))
480 "type mismatch"
481)
482
483(assert_invalid
484 (module (func $type-br_if-cond-num-vs-num-after-unreachable
485 (block (br_if 0 (unreachable) (f32.const 0)))
486 ))
487 "type mismatch"
488)
489(assert_invalid
490 (module (func $type-br_if-num-vs-void-after-unreachable (result i32)
491 (block (result i32)
492 (block (unreachable) (br_if 1 (i32.const 0) (i32.const 0)))
493 )
494 ))
495 "type mismatch"
496)
497(assert_invalid
498 (module (func $type-br_if-num-vs-num-after-unreachable (result i32)
499 (block (result i32)
500 (block (result f32) (unreachable) (br_if 1 (i32.const 0) (i32.const 0)))
501 (drop) (i32.const 0)
502 )
503 ))
504 "type mismatch"
505)
506(assert_invalid
507 (module (func $type-br_if-num2-vs-num-after-unreachable (result i32)
508 (block (result i32)
509 (unreachable) (br_if 0 (i32.const 0) (i32.const 0)) (i32.const 0)
510 )
511 ))
512 "type mismatch"
513)
514(assert_invalid
515 (module (func $type-br_table-num-vs-num-after-unreachable
516 (block (br_table 0 (unreachable) (f32.const 1)))
517 ))
518 "type mismatch"
519)
520(assert_invalid
521 (module (func $type-br_table-label-num-vs-num-after-unreachable (result i32)
522 (block (result i32) (unreachable) (br_table 0 (f32.const 0) (i32.const 1)))
523 ))
524 "type mismatch"
525)
526(assert_invalid
527 (module (func $type-br_table-label-num-vs-label-void-after-unreachable
528 (block
529 (block (result f32)
530 (unreachable)
531 (br_table 0 1 0 (i32.const 1))
532 )
533 (drop)
534 )
535 ))
536 "type mismatch"
537)
538
539(assert_invalid
540 (module (func $type-block-value-nested-unreachable-num-vs-void
541 (block (i32.const 3) (block (unreachable)))
542 ))
543 "type mismatch"
544)
545(assert_invalid
546 (module (func $type-block-value-nested-unreachable-void-vs-num (result i32)
547 (block (block (unreachable)))
548 ))
549 "type mismatch"
550)
551(assert_invalid
552 (module (func $type-block-value-nested-unreachable-num-vs-num (result i32)
553 (block (result i64) (i64.const 0) (block (unreachable)))
554 ))
555 "type mismatch"
556)
557(assert_invalid
558 (module (func $type-block-value-nested-unreachable-num2-vs-void (result i32)
559 (block (i32.const 3) (block (i64.const 1) (unreachable))) (i32.const 9)
560 ))
561 "type mismatch"
562)
563
564(assert_invalid
565 (module (func $type-block-value-nested-br-num-vs-void
566 (block (i32.const 3) (block (br 1)))
567 ))
568 "type mismatch"
569)
570(assert_invalid
571 (module (func $type-block-value-nested-br-void-vs-num (result i32)
572 (block (result i32) (block (br 1 (i32.const 0))))
573 ))
574 "type mismatch"
575)
576(assert_invalid
577 (module (func $type-block-value-nested-br-num-vs-num (result i32)
578 (block (result i32) (i64.const 0) (block (br 1 (i32.const 0))))
579 ))
580 "type mismatch"
581)
582
583(assert_invalid
584 (module (func $type-block-value-nested2-br-num-vs-void
585 (block (block (i32.const 3) (block (br 2))))
586 ))
587 "type mismatch"
588)
589(assert_invalid
590 (module (func $type-block-value-nested2-br-void-vs-num (result i32)
591 (block (result i32) (block (block (br 2 (i32.const 0)))))
592 ))
593 "type mismatch"
594)
595(assert_invalid
596 (module (func $type-block-value-nested2-br-num-vs-num (result i32)
597 (block (result i32)
598 (block (result i64) (i64.const 0) (block (br 2 (i32.const 0))))
599 )
600 ))
601 "type mismatch"
602)
603(assert_invalid
604 (module (func $type-block-value-nested2-br-num2-vs-void (result i32)
605 (block (i32.const 3) (block (i64.const 1) (br 1))) (i32.const 9)
606 ))
607 "type mismatch"
608)
609
610(assert_invalid
611 (module (func $type-block-value-nested-return-num-vs-void
612 (block (i32.const 3) (block (return)))
613 ))
614 "type mismatch"
615)
616(assert_invalid
617 (module (func $type-block-value-nested-return-void-vs-num (result i32)
618 (block (block (return (i32.const 0))))
619 ))
620 "type mismatch"
621)
622(assert_invalid
623 (module (func $type-block-value-nested-return-num-vs-num (result i32)
624 (block (result i64) (i64.const 0) (block (return (i32.const 0))))
625 ))
626 "type mismatch"
627)
628(assert_invalid
629 (module (func $type-block-value-nested-return-num2-vs-void (result i32)
630 (block (i32.const 3) (block (i64.const 1) (return (i32.const 0))))
631 (i32.const 9)
632 ))
633 "type mismatch"
634)
635
636(assert_invalid
637 (module (func $type-loop-value-nested-unreachable-num-vs-void
638 (loop (i32.const 3) (block (unreachable)))
639 ))
640 "type mismatch"
641)
642(assert_invalid
643 (module (func $type-loop-value-nested-unreachable-void-vs-num (result i32)
644 (loop (block (unreachable)))
645 ))
646 "type mismatch"
647)
648(assert_invalid
649 (module (func $type-loop-value-nested-unreachable-num-vs-num (result i32)
650 (loop (result i64) (i64.const 0) (block (unreachable)))
651 ))
652 "type mismatch"
653)
654
655(assert_invalid
656 (module (func $type-cont-last-void-vs-empty (result i32)
657 (loop (br 0 (nop)))
658 ))
659 "type mismatch"
660)
661(assert_invalid
662 (module (func $type-cont-last-num-vs-empty (result i32)
663 (loop (br 0 (i32.const 0)))
664 ))
665 "type mismatch"
666)
667
668(assert_invalid
669 (module (func $tee-local-unreachable-value
670 (local i32)
671 (local.tee 0 (unreachable))
672 ))
673 "type mismatch"
674)
675(assert_invalid
676 (module (func $br_if-unreachable (result i32)
677 (block (result i32)
678 (block
679 (br_if 1 (unreachable) (i32.const 0))
680 )
681 (i32.const 0)
682 )
683 ))
684 "type mismatch"
685)
686(assert_invalid
687 (module
688 (func $type-br_if-after-unreachable (result i64)
689 unreachable
690 br_if 0
691 i64.extend_i32_u
692 )
693 )
694 "type mismatch"
695)
696
697;; The first two operands should have the same type as each other
698(assert_invalid
699 (module (func (unreachable) (select (i32.const 1) (i64.const 1) (i32.const 1)) (drop)))
700 "type mismatch"
701)
702
703(assert_invalid
704 (module (func (unreachable) (select (i64.const 1) (i32.const 1) (i32.const 1)) (drop)))
705 "type mismatch"
706)
707
708;; Third operand must be i32
709(assert_invalid
710 (module (func (unreachable) (select (i32.const 1) (i32.const 1) (i64.const 1)) (drop)))
711 "type mismatch"
712)
713
714(assert_invalid
715 (module (func (unreachable) (select (i32.const 1) (i64.const 1)) (drop)))
716 "type mismatch"
717)
718
719(assert_invalid
720 (module (func (unreachable) (select (i64.const 1)) (drop)))
721 "type mismatch"
722)
723
724;; Result of select has type of first two operands (type of second operand when first one is omitted)
725(assert_invalid
726 (module (func (result i32) (unreachable) (select (i64.const 1) (i32.const 1))))
727 "type mismatch"
728)
729
730
731;; select always has non-empty result
732(assert_invalid
733 (module (func (unreachable) (select)))
734 "type mismatch"
735)
736
737(assert_invalid
738 (module (func $meet-bottom (param i32) (result externref)
739 (block $l1 (result externref)
740 (drop
741 (block $l2 (result i32)
742 (br_table $l2 $l1 $l2 (ref.null extern) (local.get 0))
743 )
744 )
745 (ref.null extern)
746 )
747 ))
748 "type mismatch"
749)
750
View as plain text