summaryrefslogtreecommitdiff
path: root/test/mono/control_deps.sail
blob: eaefd129fad5fc9d84bc2106d36cc67b266cd1df (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
(* Test monomorphisation control dependencies *)

default Order dec

val (bool,bool) -> unit effect pure f

function f(nosplit,split) = {
  if nosplit then {
    let (exist 'x, true. [:'x:]) 'x = if split then 16 else 32 in
    let (bit['x]) v = extz(0b0) in
    ()
  } else ()
}

val (bool,bool) -> unit effect pure g

function g(split,nosplit) = {
  (exist 'x, true. [:'x:]) x := 16;
  (exist 'y, true. [:'y:]) y := 16;
  if split then
    x := 32
  else
    ();
  if nosplit then
    y := 32
  else
    ();
  let (exist 'z, true. [:'z:]) 'z = x in
  let (bit['z]) v = extz(0b0) in
  ()
}

typedef exception = unit

val bool -> unit effect {escape} h

(* Note: we don't really need to split on b, but it's awkward to avoid.
   The important bit is not to overreact to the exception. *)
function h(b) = {
  let (exist 'x, true. [:'x:]) 'x =
    if b then 16 else throw () in
  let (bit['x]) v = extz(0b0) in
  ()
}