From 98e9487509f11fa792aafe1bc6c62d3bf48d13fc Mon Sep 17 00:00:00 2001 From: CharlieTap Date: Sun, 19 Jul 2026 11:32:47 +0100 Subject: [PATCH 1/3] [spec] test subsumption in return call result types --- test/core/gc/type-subtyping.wast | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/core/gc/type-subtyping.wast b/test/core/gc/type-subtyping.wast index b507c5a6bc..086299f1af 100644 --- a/test/core/gc/type-subtyping.wast +++ b/test/core/gc/type-subtyping.wast @@ -112,6 +112,23 @@ ) ) +(module + (func $f (result (ref array)) unreachable) + (func (result (ref eq)) + return_call $f + ) +) + +(assert_invalid + (module + (func $f (result (ref eq)) unreachable) + (func (result (ref array)) + return_call $f + ) + ) + "type mismatch" +) + (module (rec (type $f1 (sub (func))) (type (struct (field (ref $f1))))) (rec (type $f2 (sub (func))) (type (struct (field (ref $f2))))) @@ -399,6 +416,27 @@ (assert_trap (invoke "fail1") "indirect call type mismatch") (assert_trap (invoke "fail2") "indirect call type mismatch") +(module + (type $t (func (result (ref array)))) + (table 0 funcref) + (func (result (ref eq)) + i32.const 0 + return_call_indirect (type $t) + ) +) + +(assert_invalid + (module + (type $t (func (result (ref eq)))) + (table 0 funcref) + (func (result (ref array)) + i32.const 0 + return_call_indirect (type $t) + ) + ) + "type mismatch" +) + (module (rec (type $f1 (sub (func))) (type (struct (field (ref $f1))))) (rec (type $f2 (sub (func))) (type (struct (field (ref $f2))))) From 1e48b58684e6ec6def37c0c6c59ff1782f994e27 Mon Sep 17 00:00:00 2001 From: CharlieTap Date: Sun, 19 Jul 2026 17:50:11 +0100 Subject: [PATCH 2/3] use folded expression style and relocate tests --- test/core/gc/type-subtyping.wast | 48 +++++++++++++++----------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/test/core/gc/type-subtyping.wast b/test/core/gc/type-subtyping.wast index 086299f1af..4756a1fad3 100644 --- a/test/core/gc/type-subtyping.wast +++ b/test/core/gc/type-subtyping.wast @@ -113,17 +113,36 @@ ) (module - (func $f (result (ref array)) unreachable) + (func $f (result (ref array)) (unreachable)) (func (result (ref eq)) - return_call $f + (return_call $f) ) ) (assert_invalid (module - (func $f (result (ref eq)) unreachable) + (func $f (result (ref eq)) (unreachable)) (func (result (ref array)) - return_call $f + (return_call $f) + ) + ) + "type mismatch" +) + +(module + (type $t (func (result (ref array)))) + (table 0 funcref) + (func (result (ref eq)) + (return_call_indirect (type $t) (i32.const 0)) + ) +) + +(assert_invalid + (module + (type $t (func (result (ref eq)))) + (table 0 funcref) + (func (result (ref array)) + (return_call_indirect (type $t) (i32.const 0)) ) ) "type mismatch" @@ -416,27 +435,6 @@ (assert_trap (invoke "fail1") "indirect call type mismatch") (assert_trap (invoke "fail2") "indirect call type mismatch") -(module - (type $t (func (result (ref array)))) - (table 0 funcref) - (func (result (ref eq)) - i32.const 0 - return_call_indirect (type $t) - ) -) - -(assert_invalid - (module - (type $t (func (result (ref eq)))) - (table 0 funcref) - (func (result (ref array)) - i32.const 0 - return_call_indirect (type $t) - ) - ) - "type mismatch" -) - (module (rec (type $f1 (sub (func))) (type (struct (field (ref $f1))))) (rec (type $f2 (sub (func))) (type (struct (field (ref $f2))))) From 25d8d85ca1403d44dbf018a28f20a85042cdf84a Mon Sep 17 00:00:00 2001 From: CharlieTap Date: Wed, 22 Jul 2026 20:32:32 +0100 Subject: [PATCH 3/3] rework tests into non gc suites --- test/core/gc/type-subtyping.wast | 36 ----------------------------- test/core/return_call.wast | 14 +++++++++++ test/core/return_call_indirect.wast | 19 +++++++++++++++ 3 files changed, 33 insertions(+), 36 deletions(-) diff --git a/test/core/gc/type-subtyping.wast b/test/core/gc/type-subtyping.wast index 4756a1fad3..b507c5a6bc 100644 --- a/test/core/gc/type-subtyping.wast +++ b/test/core/gc/type-subtyping.wast @@ -112,42 +112,6 @@ ) ) -(module - (func $f (result (ref array)) (unreachable)) - (func (result (ref eq)) - (return_call $f) - ) -) - -(assert_invalid - (module - (func $f (result (ref eq)) (unreachable)) - (func (result (ref array)) - (return_call $f) - ) - ) - "type mismatch" -) - -(module - (type $t (func (result (ref array)))) - (table 0 funcref) - (func (result (ref eq)) - (return_call_indirect (type $t) (i32.const 0)) - ) -) - -(assert_invalid - (module - (type $t (func (result (ref eq)))) - (table 0 funcref) - (func (result (ref array)) - (return_call_indirect (type $t) (i32.const 0)) - ) - ) - "type mismatch" -) - (module (rec (type $f1 (sub (func))) (type (struct (field (ref $f1))))) (rec (type $f2 (sub (func))) (type (struct (field (ref $f2))))) diff --git a/test/core/return_call.wast b/test/core/return_call.wast index 2a983530a6..e1bb0ed27a 100644 --- a/test/core/return_call.wast +++ b/test/core/return_call.wast @@ -91,6 +91,11 @@ (func (export "type-f64-i64-to-i32-f32") (param f64 i64) (result i32 f32) (return_call $swizzle (local.get 0) (local.get 1)) ) + + ;; Result subtyping + (type $t (func)) + (func $f (result (ref null $t)) (ref.null $t)) + (func (export "type-funcref") (result funcref) (return_call $f)) ) (assert_return (invoke "type-i32") (i32.const 0x132)) @@ -134,6 +139,7 @@ (assert_return (invoke "odd" (i64.const 999_999)) (i32.const 44)) (assert_return (invoke "tailprint_i32_f32" (i32.const 5) (f32.const 91.0))) (assert_return (invoke "type-f64-i64-to-i32-f32" (f64.const 4.2) (i64.const 99)) (i32.const 99) (f32.const 4.2)) +(assert_return (invoke "type-funcref") (ref.null func)) ;; Invalid typing @@ -151,6 +157,14 @@ ) "type mismatch" ) +(assert_invalid + (module + (type $t (func)) + (func $type-ref-vs-funcref (result (ref null $t)) (return_call 1)) + (func (result funcref) (unreachable)) + ) + "type mismatch" +) (assert_invalid (module diff --git a/test/core/return_call_indirect.wast b/test/core/return_call_indirect.wast index a543d9d026..8c6292fd92 100644 --- a/test/core/return_call_indirect.wast +++ b/test/core/return_call_indirect.wast @@ -234,6 +234,14 @@ (func (export "call_mpmr") (param f64 i64) (result i32 f32) (return_call_indirect $tab4 (param f64 i64) (result i32 f32) (local.get 0) (local.get 1) (i32.const 1)) ) + + ;; Result subtyping + (type $t (func)) + (func $f (result (ref null $t)) (ref.null $t)) + (table $tab5 funcref (elem $f)) + (func (export "type-funcref") (result funcref) + (return_call_indirect $tab5 (result (ref null $t)) (i32.const 0)) + ) ) (assert_return (invoke "type-i32") (i32.const 0x132)) @@ -294,6 +302,7 @@ (assert_return (invoke "call_tailprint" (i32.const 5) (f32.const 91.0))) (assert_return (invoke "call_mpmr" (f64.const 4.2) (i64.const 99)) (i32.const 99) (f32.const 4.2)) +(assert_return (invoke "type-funcref") (ref.null func)) ;; Invalid syntax @@ -447,6 +456,16 @@ ) "type mismatch" ) +(assert_invalid + (module + (type $t (func)) + (table 0 funcref) + (func $type-ref-vs-funcref (result (ref null $t)) + (return_call_indirect (result funcref) (i32.const 0)) + ) + ) + "type mismatch" +) (assert_invalid (module