From bd379654d353b91753b2acf0a449a8a19fd948df Mon Sep 17 00:00:00 2001 From: Jeongwon Park Date: Mon, 24 Aug 2026 20:05:26 +0900 Subject: [PATCH] fix(interpreter): reject subtypes with multiple supertypes --- interpreter/valid/valid.ml | 1 + test/core/gc/type-subtyping.wast | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index 819a97fbfe..9b3756a54c 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -159,6 +159,7 @@ let check_comptype (c : context) (ct : comptype) at = let check_subtype (c : context) (sut : subtype) at = let SubT (_fin, uts, ct) = sut in + require (List.length uts <= 1) at "multiple supertypes"; List.iter (fun ut -> check_typeuse c ut at) uts; check_comptype c ct at diff --git a/test/core/gc/type-subtyping.wast b/test/core/gc/type-subtyping.wast index b507c5a6bc..e2775ae5cc 100644 --- a/test/core/gc/type-subtyping.wast +++ b/test/core/gc/type-subtyping.wast @@ -949,6 +949,15 @@ "sub type" ) +;; Testing the number of allowed supertypes + +(assert_invalid + (module + (type $parent1 (sub (struct))) + (type $parent2 (sub (struct))) + (type $child (sub $parent1 $parent2 (struct)))) + "multiple supertypes" +) ;; Testing exported functions with non-flat types (module