diff options
Diffstat (limited to 'test/lit/passes/gto-mutability.wast')
-rw-r--r-- | test/lit/passes/gto-mutability.wast | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/lit/passes/gto-mutability.wast b/test/lit/passes/gto-mutability.wast index 13b416b1b..3b01572c8 100644 --- a/test/lit/passes/gto-mutability.wast +++ b/test/lit/passes/gto-mutability.wast @@ -652,3 +652,39 @@ ) ) ) + +;; The parent is public, which prevents us from making any field immutable in +;; the child. +(module + ;; CHECK: (type $parent (sub (struct (field (mut i32))))) + (type $parent (sub (struct (field (mut i32))))) + ;; CHECK: (type $1 (func)) + + ;; CHECK: (type $child (sub $parent (struct (field (mut i32))))) + (type $child (sub $parent (struct (field (mut i32))))) + + ;; CHECK: (global $global (ref $parent) (struct.new $parent + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: )) + (global $global (ref $parent) (struct.new $parent + (i32.const 0) + )) + + ;; Make the parent public by exporting the global. + ;; CHECK: (export "global" (global $global)) + (export "global" (global $global)) + + ;; CHECK: (func $func (type $1) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (struct.new_default $child) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $func + ;; Create the child so the type is used. No sets to the fields exist, so + ;; in theory all fields could be immutable. + (drop + (struct.new_default $child) + ) + ) +) + |