diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/passes/local-subtyping-nn.wast | 39 | ||||
-rw-r--r-- | test/lit/passes/local-subtyping.wast | 26 |
2 files changed, 64 insertions, 1 deletions
diff --git a/test/lit/passes/local-subtyping-nn.wast b/test/lit/passes/local-subtyping-nn.wast index 7eca6558a..2a1a368e6 100644 --- a/test/lit/passes/local-subtyping-nn.wast +++ b/test/lit/passes/local-subtyping-nn.wast @@ -20,6 +20,9 @@ ;; CHECK-NEXT: (local.set $y ;; CHECK-NEXT: (ref.func $i32) ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $non-nullable (local $x (ref null $struct)) @@ -28,10 +31,44 @@ (local.set $x (ref.as_non_null (ref.null $struct)) ) - ;; x is assigned a value that is non-nullable, and also allows a more + ;; y is assigned a value that is non-nullable, and also allows a more ;; specific heap type. (local.set $y (ref.func $i32) ) + ;; Verify that the presence of a get does not alter things. + (drop + (local.get $x) + ) + ) + + ;; CHECK: (func $uses-default (param $i i32) + ;; CHECK-NEXT: (local $x (ref null $struct)) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $i) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (ref.as_non_null + ;; CHECK-NEXT: (ref.null $struct) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $uses-default (param $i i32) + (local $x (ref null any)) + (if + (local.get $i) + ;; The only set to this local uses a non-nullable type. + (local.set $x + (ref.as_non_null (ref.null $struct)) + ) + ) + (drop + ;; This get may use the null value, so we can refine the heap type but not + ;; alter nullability. + (local.get $x) + ) ) ) diff --git a/test/lit/passes/local-subtyping.wast b/test/lit/passes/local-subtyping.wast index 2f5c4dc4f..27f0fe1d0 100644 --- a/test/lit/passes/local-subtyping.wast +++ b/test/lit/passes/local-subtyping.wast @@ -223,4 +223,30 @@ ) ) ) + + ;; CHECK: (func $uses-default (param $i i32) + ;; CHECK-NEXT: (local $x (ref null $i32_=>_none)) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $i) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (ref.func $uses-default) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $uses-default (param $i i32) + (local $x anyref) + (if + (local.get $i) + ;; The only set to this local uses a more specific type than anyref. + (local.set $x (ref.func $uses-default)) + ) + (drop + ;; This get may use the default value, but it is ok to have a null of a + ;; more refined type in the local. + (local.get $x) + ) + ) ) |