From 1fbac7a08090d3835aa590d16bf9b1e34fdb0326 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Wed, 21 Jan 2026 10:21:00 -0600 Subject: [PATCH 1/2] Add spec tests for zero-length import groups --- .../binary-compact-imports.wast | 33 +++++++++++-------- .../imports-compact.wast | 4 +++ 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/test/core/compact-import-section/binary-compact-imports.wast b/test/core/compact-import-section/binary-compact-imports.wast index bf5d9e021..eb9140dfc 100644 --- a/test/core/compact-import-section/binary-compact-imports.wast +++ b/test/core/compact-import-section/binary-compact-imports.wast @@ -16,13 +16,16 @@ (module binary "\00asm" "\01\00\00\00" "\01\05\01\60\00\01\7f" ;; Type section: (type (func (result i32))) - "\02\0e" ;; Import section - "\01" ;; 1 group + "\02\13" ;; Import section + "\02" ;; 2 groups + "\01x" ;; "x" + "\00" "\7f" ;; "" + 0x7f (compact encoding 1) + "\00" ;; 0 items "\01a" ;; "a" - "\00" "\7f" ;; "" + 0x7f (compact encoding) - "\02" ;; 2 items - "\01b" "\00\00" ;; "b" (func (type 0)) - "\01c" "\00\00" ;; "c" (func (type 0)) + "\00" "\7f" ;; "" + 0x7f (compact encoding 1) + "\02" ;; 2 items + "\01b" "\00\00" ;; "b" (func (type 0)) + "\01c" "\00\00" ;; "c" (func (type 0)) "\03\02" "\01" ;; Function section, 1 func "\00" ;; func 2: type 0 "\07\08" "\01" ;; Export section, 1 export @@ -39,14 +42,18 @@ (module binary "\00asm" "\01\00\00\00" "\01\05\01\60\00\01\7f" ;; Type section: (type (func (result i32))) - "\02\0c" ;; Import section - "\01" ;; 1 group + "\02\13" ;; Import section + "\01" ;; 2 groups + "\01x" ;; "x" + "\00" "\7e" ;; "" + 0x7e (compact encoding 2) + "\00\00" ;; (func (type 0)) + "\00" ;; 0 items "\01a" ;; "a" - "\00" "\7e" ;; "" + 0x7e (compact encoding) - "\00\00" ;; (func (type 0)) - "\02" ;; 2 items - "\01b" ;; "b" - "\01c" ;; "c" + "\00" "\7e" ;; "" + 0x7e (compact encoding 2) + "\00\00" ;; (func (type 0)) + "\02" ;; 2 items + "\01b" ;; "b" + "\01c" ;; "c" "\03\02" "\01" ;; Function section, 1 func "\00" ;; func 2: type 0 "\07\08" "\01" ;; Export section, 1 export diff --git a/test/core/compact-import-section/imports-compact.wast b/test/core/compact-import-section/imports-compact.wast index 43422356b..5e4676b8f 100644 --- a/test/core/compact-import-section/imports-compact.wast +++ b/test/core/compact-import-section/imports-compact.wast @@ -14,6 +14,10 @@ ;; Basic behavior (module + ;; Empty groups which should not affect anything + (import "test") + (import "test" (global i32)) + (import "test" (item "func->11i" (func (result i32))) (item "func->22f" (func (result f32))) From bb886b5999fde7280b548aaef696b789938c431c Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Thu, 29 Jan 2026 12:30:51 -0600 Subject: [PATCH 2/2] Remove zero-length entries from the text format tests --- test/core/compact-import-section/imports-compact.wast | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/core/compact-import-section/imports-compact.wast b/test/core/compact-import-section/imports-compact.wast index 5e4676b8f..43422356b 100644 --- a/test/core/compact-import-section/imports-compact.wast +++ b/test/core/compact-import-section/imports-compact.wast @@ -14,10 +14,6 @@ ;; Basic behavior (module - ;; Empty groups which should not affect anything - (import "test") - (import "test" (global i32)) - (import "test" (item "func->11i" (func (result i32))) (item "func->22f" (func (result f32)))