summaryrefslogtreecommitdiff
path: root/test/lit/passes/local-subtyping-nn.wast
diff options
context:
space:
mode:
Diffstat (limited to 'test/lit/passes/local-subtyping-nn.wast')
-rw-r--r--test/lit/passes/local-subtyping-nn.wast37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/lit/passes/local-subtyping-nn.wast b/test/lit/passes/local-subtyping-nn.wast
new file mode 100644
index 000000000..7eca6558a
--- /dev/null
+++ b/test/lit/passes/local-subtyping-nn.wast
@@ -0,0 +1,37 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
+;; RUN: wasm-opt %s --local-subtyping -all --enable-gc-nn-locals -S -o - \
+;; RUN: | filecheck %s
+
+(module
+ ;; CHECK: (type $struct (struct ))
+ (type $struct (struct))
+
+ ;; CHECK: (import "out" "i32" (func $i32 (result i32)))
+ (import "out" "i32" (func $i32 (result i32)))
+
+ ;; CHECK: (func $non-nullable
+ ;; CHECK-NEXT: (local $x (ref $struct))
+ ;; CHECK-NEXT: (local $y (ref $none_=>_i32))
+ ;; CHECK-NEXT: (local.set $x
+ ;; CHECK-NEXT: (ref.as_non_null
+ ;; CHECK-NEXT: (ref.null $struct)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.set $y
+ ;; CHECK-NEXT: (ref.func $i32)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $non-nullable
+ (local $x (ref null $struct))
+ (local $y anyref)
+ ;; x is assigned a value that is non-nullable.
+ (local.set $x
+ (ref.as_non_null (ref.null $struct))
+ )
+ ;; x is assigned a value that is non-nullable, and also allows a more
+ ;; specific heap type.
+ (local.set $y
+ (ref.func $i32)
+ )
+ )
+)