Debian Codegraph @

tests/cli/folding/fold-stack-switching.wast

raw
1 ;; RUN: wast --assert default,snapshot-folded --snapshot tests/snapshots % -f stack-switching
2
3 ;; This file tests validation only, without GC types and subtyping.
4
5
6 ;;;;
7 ;;;; WasmFX types
8 ;;;;
9
10 (module
11 (type $ft1 (func))
12 (type $ct1 (cont $ft1))
13
14 (type $ft2 (func (param i32) (result i32)))
15 (type $ct2 (cont $ft2))
16
17 (func $test
18 (param $p1 (ref cont))
19 (param $p2 (ref nocont))
20 (param $p3 (ref $ct1))
21
22 (local $x1 (ref cont))
23 (local $x2 (ref nocont))
24 (local $x3 (ref $ct1))
25 (local $x4 (ref $ct2))
26 (local $x5 (ref null $ct1))
27
28 ;; nocont <: cont
29 (local.set $x1 (local.get $p2))
30
31 ;; nocont <: $ct1
32 (local.set $x3 (local.get $p2))
33
34 ;; $ct1 <: $cont
35 (local.set $x3 (local.get $p3))
36
37 ;; (ref $ct1) <: (ref null $cont)
38 (local.set $x5 (local.get $p3))
39 )
40 )
41
42 (assert_invalid
43 (module
44 (type $ft1 (func))
45 (type $ct1 (cont $ft1))
46
47 (type $ft2 (func (param i32) (result i32)))
48 (type $ct2 (cont $ft2))
49
50 (func $test
51 (param $p1 (ref cont))
52 (param $p2 (ref nocont))
53 (param $p3 (ref $ct1))
54
55 (local $x1 (ref cont))
56 (local $x2 (ref nocont))
57 (local $x3 (ref $ct1))
58 (local $x4 (ref $ct2))
59 (local $x5 (ref null $ct1))
60
61 ;; cont </: nocont
62 (local.set $p2 (local.get $p1))
63 )
64 )
65 "type mismatch"
66 )
67
68 (assert_invalid
69 (module
70 (type $ft1 (func))
71 (type $ct1 (cont $ft1))
72
73 (type $ft2 (func (param i32) (result i32)))
74 (type $ct2 (cont $ft2))
75
76 (func $test
77 (param $p1 (ref cont))
78 (param $p2 (ref nocont))
79 (param $p3 (ref $ct1))
80
81 (local $x1 (ref cont))
82 (local $x2 (ref nocont))
83 (local $x3 (ref $ct1))
84 (local $x4 (ref $ct2))
85 (local $x5 (ref null $ct1))
86
87 ;; $ct1 </: nocont
88 (local.set $p2 (local.get $p3))
89 )
90 )
91 "type mismatch"
92 )
93
94 (assert_invalid
95 (module
96 (type $ft1 (func))
97 (type $ct1 (cont $ft1))
98
99 (type $ft2 (func (param i32) (result i32)))
100 (type $ct2 (cont $ft2))
101
102 (func $test
103 (param $p1 (ref cont))
104 (param $p2 (ref nocont))
105 (param $p3 (ref $ct1))
106
107 (local $x1 (ref cont))
108 (local $x2 (ref nocont))
109 (local $x3 (ref $ct1))
110 (local $x4 (ref $ct2))
111 (local $x5 (ref null $ct1))
112
113 ;; $cont </: $ct1
114 (local.set $p3 (local.get $p1))
115 )
116 )
117 "type mismatch"
118 )
119
120 (assert_invalid
121 (module
122 (type $ft1 (func))
123 (type $ct1 (cont $ft1))
124
125 (type $ft2 (func (param i32) (result i32)))
126 (type $ct2 (cont $ft2))
127
128 (func $test
129 (param $p1 (ref cont))
130 (param $p2 (ref nocont))
131 (param $p3 (ref $ct1))
132 (param $p4 (ref $ct2))
133 (param $p5 (ref null $ct1))
134
135
136 (local $x1 (ref cont))
137 (local $x2 (ref nocont))
138 (local $x3 (ref $ct1))
139 (local $x4 (ref $ct2))
140 (local $x5 (ref null $ct1))
141
142 ;; (ref null $ct1) </: (ref $cont)
143 (local.set $x3 (local.get $p5))
144 )
145 )
146 "type mismatch"
147 )
148
149 (assert_invalid
150 (module
151 (type $ft1 (func))
152 (type $ct1 (cont $ft1))
153
154 (type $ft2 (func (param i32) (result i32)))
155 (type $ct2 (cont $ft2))
156
157 (func $test
158 (param $p1 (ref cont))
159 (param $p2 (ref nocont))
160 (param $p3 (ref $ct1))
161 (param $p4 (ref $ct2))
162 (param $p5 (ref null $ct1))
163
164
165 (local $x1 (ref cont))
166 (local $x2 (ref nocont))
167 (local $x3 (ref $ct1))
168 (local $x4 (ref $ct2))
169 (local $x5 (ref null $ct1))
170
171 ;; (ref $ct1) </: (ref $ct2)
172 (local.set $p4 (local.get $p3))
173 )
174 )
175 "type mismatch"
176 )
177
178 ;;;;
179 ;;;; cont_bind instructions
180 ;;;;
181
182 (module
183 (type $ft0 (func (result i32)))
184 (type $ct0 (cont $ft0))
185
186 (type $ft1 (func (param i32) (result i32)))
187 (type $ct1 (cont $ft1))
188
189 (type $ft2 (func (param i64 i32) (result i32)))
190 (type $ct2 (cont $ft2))
191
192
193 (func $test1
194 (param $p_ct1 (ref null $ct1))
195 (result (ref $ct0))
196
197 ;; cont.bind takes nullable ref, returns non-nullable one
198 (i32.const 123)
199 (local.get $p_ct1)
200 (cont.bind $ct1 $ct0)
201 )
202
203 (func $test2
204 (param $p_ct2 (ref $ct2))
205 (result (ref $ct1))
206
207 ;; cont.bind does not have to apply continuation fully
208 (i64.const 123)
209 (local.get $p_ct2)
210 (cont.bind $ct2 $ct1)
211 )
212
213 (func $test3
214 (param $p_ct1 (ref $ct1))
215 (result (ref $ct1))
216
217 ;; cont.bind can take same type twice, not actually apply anything
218 (local.get $p_ct1)
219 (cont.bind $ct1 $ct1)
220 )
221
222
223 )
224
225 (assert_invalid
226
227 (module
228 (type $ft0 (func (result i32)))
229 (type $ct0 (cont $ft0))
230
231 (func $error
232 (param $p_ft0 (ref $ft0))
233 ;; error: non-continuation type on cont.bind
234 (local.get $p_ft0)
235 (cont.bind $ft0 $ft0)
236 (drop)
237 )
238 )
239 "non-continuation type"
240 )
241
242 ;; cont.new type mismatch: passing a continuation reference to cont.new instead of function reference
243 ;; This is actually just checking type-matching, not cont.new specific:
244 ;; (ref null $ct1) is not a subtype of (ref null $ft1)
245
246 (assert_invalid
247
248 (module
249 (type $ft0 (func (result i32)))
250 (type $ct0 (cont $ft0))
251
252 (type $ft1 (func (param i32) (result i32)))
253 (type $ct1 (cont $ft1))
254
255 (func $error
256 (param $p_ct1 (ref $ct1))
257 ;; cont.bind type mismatch: passing wrong kind of continuation.
258 ;; This is actually just checking type-matching, not cont.bind specific.
259 (local.get $p_ct1)
260 (cont.bind $ct0 $ct0)
261 (drop)
262 )
263 )
264 "type mismatch"
265 )
266
267 (assert_invalid
268
269 (module
270 (type $ft0 (func (result i32)))
271 (type $ct0 (cont $ft0))
272
273 (type $ft1 (func (param i32) (result i32)))
274 (type $ct1 (cont $ft1))
275
276 (type $ft2 (func (param i64 i32) (result i32)))
277 (type $ct2 (cont $ft2))
278
279
280 (type $ft1_alt (func (param i64) (result i32)))
281 (type $ct1_alt (cont $ft1_alt))
282
283 (func $error
284 (param $p_ct2 (ref $ct2))
285 ;; error: two continuation types not agreeing on arg types
286 (i64.const 123)
287 (local.get $p_ct2)
288 (cont.bind $ct2 $ct1_alt)
289 (drop)
290 )
291 )
292 "type mismatch"
293 )
294
295 (assert_invalid
296
297 (module
298 (type $ft0 (func (result i32)))
299 (type $ct0 (cont $ft0))
300
301 (type $ft1 (func (param i32) (result i32)))
302 (type $ct1 (cont $ft1))
303
304 (type $ft2 (func (param i64 i32) (result i32)))
305 (type $ct2 (cont $ft2))
306
307
308 (type $ft1_alt (func (param i32) (result i64)))
309 (type $ct1_alt (cont $ft1_alt))
310
311 (func $error
312 (param $p_ct2 (ref $ct2))
313 ;; error: two continuation types not agreeing on return types
314 (i64.const 123)
315 (local.get $p_ct2)
316 (cont.bind $ct2 $ct1_alt)
317 (drop)
318 )
319 )
320 "type mismatch"
321 )
322
323 (assert_invalid
324
325 (module
326 (type $ft0 (func (result i32)))
327 (type $ct0 (cont $ft0))
328
329 (type $ft1 (func (result i32 i32)))
330 (type $ct1 (cont $ft1))
331
332 (func $error
333 (param $p (ref $ct0))
334 ;; error: two continuation types not agreeing on return types
335 (local.get $p)
336 (cont.bind $ct0 $ct1)
337 (drop)
338 )
339 )
340 "type mismatch"
341 )
342
343 (assert_invalid
344
345 (module
346 (type $ft0 (func (result i32)))
347 (type $ct0 (cont $ft0))
348
349 (type $ft1 (func (param i32) (result i32)))
350 (type $ct1 (cont $ft1))
351
352 (func $error
353 (param $p_ct0 (ref $ct0))
354 ;; error: trying to go from 0 to 1 args
355 (local.get $p_ct0)
356 (cont.bind $ct0 $ct1)
357 (drop)
358 )
359 )
360 "type mismatch"
361 )
362
363 (assert_invalid
364
365 (module
366 (type $ft0 (func (result i32)))
367 (type $ct0 (cont $ft0))
368
369 (type $ft1 (func (param i32) (result i32)))
370 (type $ct1 (cont $ft1))
371
372
373 (func $error
374 (param $p_ct1 (ref $ct1))
375 ;; error: Insufficient arguments::
376 ;; This is really testing the general application of arguments to instructions,
377 ;; but trying to trick parsers of the folded form
378 (cont.bind $ct1 $ct0 (local.get $p_ct1))
379 (drop)
380 )
381 )
382 "type mismatch"
383 )
384
385 (assert_invalid
386
387 (module
388 (type $ft0 (func (result i32)))
389 (type $ct0 (cont $ft0))
390
391 (type $ft1 (func (param i32) (result i32)))
392 (type $ct1 (cont $ft1))
393
394 (func $error
395 (param $p_ct1 (ref $ct1))
396 ;; error: Too many arguments::
397 ;; This is really testing the general application of arguments to instructions,
398 ;; but trying to trick parsers of the folded form
399 (cont.bind $ct1 $ct0 (i32.const 123) (i32.const 123) (local.get $p_ct1))
400 (drop)
401 )
402 )
403 "type mismatch"
404 )
405
406 ;;;;
407 ;;;; cont_new instructions
408 ;;;;
409
410 (module
411 (type $ft1 (func (param i32) (result i32)))
412 (type $ct1 (cont $ft1))
413
414 (type $ft2 (func (param i32 i32) (result i32)))
415 (type $ct2 (cont $ft2))
416
417 (func $f1 (export "f1") (param i32) (result i32)
418 (i32.const 123)
419 )
420
421 (func $drop_ct1 (param $c (ref $ct1)))
422
423 ;; simple smoke test
424 (func $test_good1 (param $x (ref $ft1)) (result (ref $ct1))
425 (local.get $x)
426 (cont.new $ct1)
427 )
428
429 ;; cont.new takes a nullable function
430 (func $test_good2 (param $x (ref null $ft1)) (result (ref $ct1))
431 (local.get $x)
432 (cont.new $ct1)
433 )
434
435
436 )
437
438 (assert_invalid
439 (module
440 (type $ft1 (func (param i32) (result i32)))
441 (type $ct1 (cont $ft1))
442
443 (func $bad (param $x (ref null $ct1)) (result (ref $ct1))
444 (local.get $x)
445 (cont.new $ct1)
446 )
447 )
448 ;; cont.new type mismatch: passing a continuation reference to cont.new instead of function reference
449 ;; This is actually just checking type-matching, not cont.new specific:
450 ;; (ref null $ct1) is not a subtype of (ref null $ft1)
451 "type mismatch"
452 )
453
454 (assert_invalid
455 (module
456 (type $ft1 (func (param i32) (result i32)))
457 (type $ct1 (cont $ft1))
458
459 (type $ft2 (func (param i32 i32) (result i32)))
460 (type $ct2 (cont $ft2))
461
462 (func $drop_ct1 (param $c (ref $ct1)))
463
464 (func $bad (param $x (ref null $ft2)) (result (ref $ct1))
465 (local.get $x)
466 (cont.new $ct1)
467 )
468 )
469 ;; cont.new type mismatch: passing function of wrong type to cont.new
470 ;; This is actually just checking type-matching, not cont.new specific:
471 ;; (ref null $ft2) is not a subtype of (ref null $ft1)
472 "type mismatch"
473 )
474
475 (assert_invalid
476 (module
477 (type $ft1 (func (param i32) (result i32)))
478 (type $ct1 (cont $ft1))
479
480 (func $bad (param $x (ref null $ct1))
481 (local.get $x)
482 (cont.new $ft1)
483 (drop)
484 )
485 )
486 ;; non-continuation type on cont.new
487 "non-continuation type 0"
488 )
489
490 ;;;;
491 ;;;; resume instructions
492 ;;;;
493
494
495 (module
496 (type $ft0 (func))
497 (type $ct0 (cont $ft0))
498
499 (type $ft1 (func (param f32) (result f64)))
500 (type $ct1 (cont $ft1))
501
502 (type $ft2 (func (param i64) (result f64)))
503 (type $ct2 (cont $ft2))
504
505 (type $ft3 (func (param i32) (result f64)))
506 (type $ct3 (cont $ft3))
507
508 (tag $t0)
509 (tag $t1)
510 (tag $t2 (param i32) (result i64))
511 (tag $t3 (param i64) (result i32))
512
513 ;; Multiple tags, all types handled correctly
514 (func $test0 (param $x (ref $ct1)) (result f64)
515 (block $handler0 (result i32 (ref $ct2))
516 (block $handler1 (result i64 (ref $ct3))
517 (f32.const 1.23)
518 (local.get $x)
519 (resume $ct1 (on $t2 $handler0) (on $t3 $handler1))
520 (return)
521 )
522 (unreachable)
523 )
524 (unreachable)
525 )
526
527 ;; Same as $test0, but we provide two handlers for the same tag
528 (func $test1 (param $x (ref $ct1)) (result f64)
529 (block $handler0 (result i32 (ref $ct2))
530 (block $handler1 (result i32 (ref $ct2))
531 (f32.const 1.23)
532 (local.get $x)
533 (resume $ct1 (on $t2 $handler0) (on $t2 $handler1))
534 (return)
535 )
536 (unreachable)
537 )
538 (unreachable)
539 )
540
541 ;; resume takes a nullable reference
542 (func $test2 (param $x (ref null $ct0))
543 (local.get $x)
544 (resume $ct0)
545 )
546
547 ;; handler blocks take the continuation as nullable ref
548 (func $test3 (param $x (ref $ct0))
549 (block $handler (result (ref null $ct0))
550 (local.get $x)
551 (resume $ct0 (on $t0 $handler))
552 (return)
553 )
554 (unreachable)
555 )
556
557 ;; Nothing wrong with using the same handler block for multiple tags
558 (func $test4 (param $x (ref $ct0))
559 (block $handler (result (ref null $ct0))
560 (local.get $x)
561 (resume $ct0 (on $t0 $handler) (on $t1 $handler))
562 (return)
563 )
564 (unreachable)
565 )
566
567 ;; handler block can have params
568 (func $test5 (param $x (ref $ct0))
569 (local.get $x)
570 (block $handler (param (ref $ct0)) (result (ref $ct0))
571 (resume $ct0 (on $t0 $handler))
572 (return)
573 )
574 (unreachable)
575 )
576 )
577
578 ;; tag does not exist
579 (assert_invalid
580 (module
581 (type $ft0 (func))
582 (type $ct0 (cont $ft0))
583 ;;(tag $t0)
584 (func $error (param $x (ref $ct0))
585 (block $handler (result (ref null $ct0))
586 (local.get $x)
587 (resume $ct0 (on 0 $handler))
588 (return)
589 )
590 (unreachable)
591 )
592
593 )
594 "unknown tag"
595 )
596
597 ;; non-continuation type on resume
598 (assert_invalid
599 (module
600 (type $ft0 (func))
601 (type $ct0 (cont $ft0))
602 (func $error (param $x (ref $ct0))
603 (local.get $x)
604 (resume $ft0)
605 )
606
607 )
608 "non-continuation type"
609 )
610
611 ;; non-continuation type on handler
612 (assert_invalid
613 (module
614 (type $ft0 (func))
615 (type $ct0 (cont $ft0))
616 (tag $t0)
617 (func $test1 (param $x (ref $ct0))
618 (block $handler (result (ref $ft0))
619 (local.get $x)
620 (resume $ct0 (on $t0 $handler))
621 (return)
622 )
623 (unreachable)
624 )
625
626 )
627 "non-continuation type"
628 )
629
630 (assert_invalid
631 (module
632 (type $ft (func (param i32)))
633 (type $ct (cont $ft))
634
635 (func $error
636 (param $p (ref $ct))
637 ;; error: Too many arguments::
638 ;; This is really testing the general application of arguments to instructions,
639 ;; but trying to trick parsers of the folded form
640 (resume $ct (i32.const 123) (i32.const 123) (local.get $p))
641 )
642 )
643 "type mismatch"
644 )
645
646 (assert_invalid
647 (module
648 (type $ft (func (param i32)))
649 (type $ct (cont $ft))
650
651 (func $error
652 (param $p (ref $ct))
653 ;; error: Too few arguments::
654 ;; This is really testing the general application of arguments to instructions,
655 ;; but trying to trick parsers of the folded form
656 (resume $ct (local.get $p))
657 )
658 )
659 "type mismatch"
660 )
661
662 (assert_invalid
663 (module
664 (type $ft0 (func (param i32)))
665 (type $ct0 (cont $ft0))
666
667 (type $ft1 (func (param i64)))
668 (type $ct1 (cont $ft1))
669
670 (func $error
671 (param $p (ref $ct1))
672 ;; error: Mismatch between annotation on resume and actual argument
673 ;; This is really testing the general application of arguments to instructions.
674 (resume $ct0 (i32.const 123) (local.get $p))
675 )
676 )
677 "type mismatch"
678 )
679
680 (assert_invalid
681 (module
682 (type $ft0 (func))
683 (type $ct0 (cont $ft0))
684
685 (tag $t (param i32))
686
687 (func $error
688 (param $p (ref $ct0))
689 (block $handler (result (ref $ct0))
690 ;; error: handler block has insufficient number of results
691 (local.get $p)
692 (resume $ct0 (on $t $handler))
693 (return)
694 )
695 (unreachable)
696 )
697 )
698 "type mismatch"
699 )
700
701 (assert_invalid
702 (module
703 (type $ft0 (func))
704 (type $ct0 (cont $ft0))
705
706 (tag $t (param i32))
707
708 (func $error
709 (param $p (ref $ct0))
710 (block $handler (result i32 i32 (ref $ct0))
711 ;; error: handler block has too many results
712 (local.get $p)
713 (resume $ct0 (on $t $handler))
714 (return)
715 )
716 (unreachable)
717 )
718 )
719 "type mismatch"
720 )
721
722 (assert_invalid
723 (module
724 (type $ft0 (func))
725 (type $ct0 (cont $ft0))
726
727 (tag $t (param i32))
728
729 (func $error
730 (param $p (ref $ct0))
731 (block $handler (result i64 (ref $ct0))
732 ;; error: type mismatch in non-continuation handler result type
733 (local.get $p)
734 (resume $ct0 (on $t $handler))
735 (return)
736 )
737 (unreachable)
738 )
739 )
740 "type mismatch"
741 )
742
743 (assert_invalid
744 (module
745 (type $ft0 (func))
746 (type $ct0 (cont $ft0))
747
748 (type $ft1 (func (param i32)))
749 (type $ct1 (cont $ft1))
750
751 (tag $t (param i32))
752
753 (func $error
754 (param $p (ref $ct0))
755 (block $handler (result i32 (ref $ct1))
756 ;; error: type mismatch in continuation handler result type
757 (local.get $p)
758 (resume $ct0 (on $t $handler))
759 (return)
760 )
761 (unreachable)
762 )
763 )
764 "type mismatch"
765 )
766
767 (assert_invalid
768 (module
769 (type $ft0 (func))
770 (type $ct0 (cont $ft0))
771
772 (type $ft1 (func (result i32)))
773 (type $ct1 (cont $ft1))
774
775 (tag $t (param i32))
776
777 (func $error
778 (param $p (ref $ct0))
779 (block $handler (result i32 (ref $ct1))
780 ;; error: type mismatch in continuation types; result types don't agree.
781 (local.get $p)
782 (resume $ct0 (on $t $handler))
783 (return)
784 )
785 (unreachable)
786 )
787 )
788 "type mismatch"
789 )
790
791 (assert_invalid
792 (module
793 (type $ft0 (func (result i32)))
794 (type $ct0 (cont $ft0))
795
796 (type $ft1 (func (result i64)))
797 (type $ct1 (cont $ft1))
798
799 (tag $t (param i32))
800
801 (func $error
802 (param $p (ref $ct0))
803 (result i32)
804 (block $handler (result i32 (ref $ct1))
805 ;; error: type mismatch in continuation types; result types don't agree.
806 (local.get $p)
807 (resume $ct0 (on $t $handler))
808 (return)
809 )
810 (unreachable)
811 )
812 )
813 "type mismatch"
814 )
815
816 ;;;;
817 ;;;; suspend instructions
818 ;;;;
819
820 (module
821 (tag $t (param i64 i32) (result i32 i64))
822
823 (func $test (result i32 i64)
824 (i64.const 123)
825 (i32.const 123)
826 (suspend $t)
827 )
828 )
829
830
831 (assert_invalid
832 (module
833 (tag $t (param i64 i32) (result i32 i64))
834
835 (func $test (result i32 i64)
836 ;; error: Insufficient arguments::
837 ;; This is really testing the general application of arguments to instructions,
838 ;; but trying to trick parsers of the folded form
839
840 (suspend $t (i64.const 123))
841 )
842 )
843 "type mismatch"
844 )
845
846 (assert_invalid
847 (module
848 (tag $t (param i32) (result i32 i64))
849
850 (func $test (result i32 i64)
851 ;; error: Too many arguments:
852 ;; This is really testing the general application of arguments to instructions,
853 ;; but trying to trick parsers of the folded form
854
855 (suspend $t (i64.const 123) (i32.const 123))
856 )
857 )
858 "type mismatch"
859 )
860
861 (assert_invalid
862 (module
863 (func $test
864 ;; error: Tag does not exist
865 (suspend 0)
866 )
867 )
868 "unknown tag"
869 )
870
871 ;; Switch
872
873 (assert_invalid
874
875 (module
876 (type $ft0 (func (result i32)))
877 (type $ct0 (cont $ft0))
878
879 (type $ft1 (func (param (ref null $ct0)) (result i32)))
880 (type $ct1 (cont $ft1))
881
882 (tag $swap (result i32 i32))
883
884 (func $error
885 (param $p (ref null $ct1))
886 ;; error: $ft1 results don't agree with $swap results.
887 (local.get $p)
888 (switch $ct1 $swap)
889 (drop)
890 )
891 )
892 "type mismatch"
893 )
894
895 (assert_invalid
896
897 (module
898 (type $ft0 (func (result i32)))
899 (type $ct0 (cont $ft0))
900
901 (type $ft1 (func (param (ref null $ct0)) (result i32 i32)))
902 (type $ct1 (cont $ft1))
903
904 (tag $swap (result i32 i32))
905
906 (func $error
907 (param $p (ref null $ct1))
908 ;; error: $ft0 results don't agree with $swap results.
909 (local.get $p)
910 (switch $ct1 $swap)
911 (drop)
912 )
913 )
914 "type mismatch"
915 )
916
917 (assert_invalid
918
919 (module
920 (type $ft0 (func (result i32)))
921 (type $ct0 (cont $ft0))
922
923 (type $ft1 (func (param (ref null $ct0)) (result i64)))
924 (type $ct1 (cont $ft1))
925
926 (tag $swap (result i32))
927
928 (func $error
929 (param $p (ref null $ct1))
930 ;; error: $ft1 results don't agree with $swap results.
931 (local.get $p)
932 (switch $ct1 $swap)
933 (drop)
934 )
935 )
936 "type mismatch"
937 )
938
939
940 (assert_invalid
941
942 (module
943 (type $ft0 (func (result f32)))
944 (type $ct0 (cont $ft0))
945
946 (type $ft1 (func (param (ref null $ct0)) (result i32)))
947 (type $ct1 (cont $ft1))
948
949 (tag $swap (result i32))
950
951 (func $error
952 (param $p (ref null $ct1))
953 ;; error: $ft0 results don't agree with $swap results.
954 (local.get $p)
955 (switch $ct1 $swap)
956 (drop)
957 )
958 )
959 "type mismatch"
960 )
961
962 (assert_invalid
963
964 (module
965 (type $ft0 (func (result i32)))
966 (type $ct0 (cont $ft0))
967
968 (type $ft1 (func (param (ref null $ct0)) (result i64)))
969 (type $ct1 (cont $ft1))
970
971 (tag $swap (result i64))
972
973 (func $error
974 (param $p (ref null $ct1))
975 ;; error: $ft0 results don't agree with $swap results.
976 (local.get $p)
977 (switch $ct1 $swap)
978 (drop)
979 )
980 )
981 "type mismatch"
982 )