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

Add some tests for invalid subtyping due to non-matching field types #573

Merged
merged 3 commits into from
Dec 5, 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
37 changes: 37 additions & 0 deletions test/core/gc/type-subtyping-invalid.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
(assert_invalid
(module
;; When fields are mutable, a subtype's reference fields cannot be subtypes of
;; the supertype's fields, they must match exactly.
(type $a (sub (struct (field (mut (ref null any))))))
(type $b (sub $a (struct (field (mut (ref null none))))))
)
"sub type 1 does not match super type"
)

(assert_invalid
(module
;; When fields are const, a subtype's reference fields cannot be supertypes of
;; the supertype's fields, they must be subtypes.
(type $a (sub (struct (field (ref null none)))))
(type $b (sub $a (struct (field (ref null any)))))
)
"sub type 1 does not match super type"
)

(assert_invalid
(module
;; The mutability of fields must be the same.
(type $c (sub (struct (field (mut (ref null any))))))
(type $d (sub $c (struct (field (ref null any)))))
)
"sub type 1 does not match super type"
)

(assert_invalid
(module
;; The mutability of fields must be the same.
(type $c (sub (struct (field (ref null any)))))
(type $d (sub $c (struct (field (mut (ref null any))))))
)
"sub type 1 does not match super type"
)
Loading