Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Test call_indirect subtyping more thoroughly #526

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions test/core/gc/type-subtyping.wast
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,34 @@
(assert_trap (invoke "fail3") "cast")
(assert_trap (invoke "fail4") "cast")

(module
(type $t1 (sub (func)))
(type $t2 (sub $t1 (func)))
(type $t3 (sub $t2 (func)))
(type $t4 (sub final (func)))

(func $f2 (type $t2))
(func $f3 (type $t3))
(table (ref null $t2) (elem $f2 $f3))

(func (export "run")
(call_indirect (type $t1) (i32.const 0))
(call_indirect (type $t1) (i32.const 1))
(call_indirect (type $t2) (i32.const 0))
(call_indirect (type $t2) (i32.const 1))
(call_indirect (type $t3) (i32.const 1))
)

(func (export "fail1")
(call_indirect (type $t3) (i32.const 0))
)
(func (export "fail2")
(call_indirect (type $t4) (i32.const 0))
)
)
(assert_return (invoke "run"))
(assert_trap (invoke "fail1") "indirect call")
(assert_trap (invoke "fail2") "indirect call")

(module
(rec (type $f1 (sub (func))) (type (struct (field (ref $f1)))))
Expand Down Expand Up @@ -740,7 +768,7 @@
"sub type"
)

(assert_invalid
(assert_invalid
(module
(type $f0 (sub (func (param i32) (result i32))))
(type $s0 (sub $f0 (struct)))
Expand All @@ -764,15 +792,15 @@
"sub type"
)

(assert_invalid
(assert_invalid
(module
(type $s0 (sub (struct)))
(type $f0 (sub $s0 (func (param i32) (result i32))))
)
"sub type"
)

(assert_invalid
(assert_invalid
(module
(type $a0 (sub (array i32)))
(type $f0 (sub $a0 (func (param i32) (result i32))))
Expand Down Expand Up @@ -803,4 +831,3 @@
)
"sub type"
)

Loading