summaryrefslogtreecommitdiff
path: root/test/lit/validation/bad-non-nullable-locals.wast
blob: f22771591c9ddc03251757a084a442b4094305b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
;; RUN: foreach %s %t not wasm-opt -all 2>&1 | filecheck %s

;; CHECK: non-nullable local's sets must dominate gets
(module
  (func $inner-to-func
    ;; a set in an inner scope does *not* help a get validate.
    (local $x (ref func))
    (block $b
      (local.set $x
        (ref.func $helper)
      )
    )
    (drop
      (local.get $x)
    )
  )

  (func $helper)
)

;; CHECK: non-nullable local's sets must dominate gets
(module
  (func $get-without-set
    (local $x (ref func))
    (drop
      (local.get $x)
    )
  )

  (func $helper)
)

;; CHECK: non-nullable local's sets must dominate gets
(module
  (func $get-before-set
    (local $x (ref func))
    (local.set $x
      (local.get $x)
    )
  )

  (func $helper)
)

;; CHECK: non-nullable local's sets must dominate gets
(module
  (func $if-arms
    (local $x (ref func))
    (if
      (i32.const 1)
      ;; Superficially the order is right, but not really.
      (local.set $x
        (ref.func $helper)
      )
      (local.get $x)
    )
  )

  (func $helper)
)