Skip to content

Commit 7a098c7

Browse files
authored
Merge branch 'main' into wat
2 parents d4c2e24 + 3ac42d8 commit 7a098c7

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

interpreter/valid/valid.ml

+4-3
Original file line numberDiff line numberDiff line change
@@ -651,14 +651,15 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : infer_in
651651
" but the type annotation has " ^ string_of_result_type ts11)
652652
in
653653
let et = tag c y in
654-
let FuncT (_, t) as ft = func_type_of_tag_type c et y.at in
655-
require (match_func_type c.types (FuncT ([], t)) ft) y.at
654+
let FuncT (ts31, t) = func_type_of_tag_type c et y.at in
655+
require (ts31 = []) y.at
656656
"type mismatch in switch tag";
657657
require (match_result_type c.types ts12 t) y.at
658658
"type mismatch in continuation types";
659659
require (match_result_type c.types t ts22) y.at
660660
"type mismatch in continuation types";
661-
ts11 --> ts21, []
661+
let ts11' = Lib.List.lead ts11 in
662+
(ts11' @ [RefT (Null, VarHT (StatX x.it))]) --> ts21, []
662663

663664
| Throw x ->
664665
let FuncT (ts1, ts2) = func_type_of_tag_type c (tag c x) x.at in

test/core/run.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
simd_test_files = glob.glob(os.path.join(inputDir, "simd", "*.wast"))
3636
gc_test_files = glob.glob(os.path.join(inputDir, "gc", "*.wast"))
3737
multi_memory_test_files = glob.glob(os.path.join(inputDir, "multi-memory", "*.wast"))
38-
all_test_files = main_test_files + simd_test_files + gc_test_files + multi_memory_test_files
38+
stack_switching_test_files = glob.glob(os.path.join(inputDir, "stack-switching", "*.wast"))
39+
all_test_files = main_test_files + simd_test_files + gc_test_files + multi_memory_test_files + stack_switching_test_files
3940

4041
wasmExec = arguments.wasm
4142
wasmCommand = wasmExec + " " + arguments.opts

test/core/stack-switching/cont.wast

+36-1
Original file line numberDiff line numberDiff line change
@@ -1031,4 +1031,39 @@
10311031
(func
10321032
suspend $swap
10331033
)
1034-
)
1034+
)
1035+
1036+
(module
1037+
(type $ft0 (func))
1038+
(type $ct0 (cont $ft0))
1039+
1040+
(type $ft1 (func (param (ref $ct0))))
1041+
(type $ct1 (cont $ft1))
1042+
1043+
(tag $t)
1044+
1045+
(func $f
1046+
(cont.new $ct1 (ref.func $g))
1047+
(switch $ct1 $t)
1048+
)
1049+
(elem declare func $f)
1050+
1051+
(func $g (param (ref $ct0)))
1052+
(elem declare func $g)
1053+
1054+
(func $entry
1055+
(cont.new $ct0 (ref.func $f))
1056+
(resume $ct0 (on $t switch))
1057+
)
1058+
)
1059+
1060+
(assert_invalid
1061+
(module
1062+
(rec
1063+
(type $ft (func (param (ref $ct))))
1064+
(type $ct (cont $ft)))
1065+
(tag $t (param i32))
1066+
1067+
(func (param $k (ref $ct))
1068+
(switch $ct $t)))
1069+
"type mismatch in switch tag")

0 commit comments

Comments
 (0)