roc/crates/compiler/test_mono/generated/match_list.txt
Ayaz Hafiz 759127660d
Spread list tests can never touch exact-sized bounds tests
When compiling a pattern match like

```
[] -> ..
[_] -> ..
[_, ..] -> ..
```

to a decision tree, we must make sure that the last test (len >= 1)
does not touch the branch reached by the second test (len == 1). It is
enough to ban (len >=) tests from ever touching exact-sized list
patterns, because a spread test (len >=) can never reach an exact-sized
test.

On the other hand, an exact-sized test can reach a spread pattern,
because in

```
[_, _] -> ..
[..] -> ..
```

the last branch generates tests for patterns `[]` and `[_]`, and we would
like those patterns to be covered by the spread test (len >= 0)!

Closes #4685
2022-12-05 13:45:35 -06:00

57 lines
2.1 KiB
Text

procedure Test.0 ():
let Test.31 : Int1 = false;
let Test.32 : Int1 = true;
let Test.1 : List Int1 = Array [Test.31, Test.32];
joinpoint Test.9:
let Test.8 : Str = "E";
ret Test.8;
in
let Test.28 : U64 = lowlevel ListLen Test.1;
let Test.29 : U64 = 0i64;
let Test.30 : Int1 = lowlevel Eq Test.28 Test.29;
if Test.30 then
dec Test.1;
let Test.4 : Str = "A";
ret Test.4;
else
let Test.25 : U64 = lowlevel ListLen Test.1;
let Test.26 : U64 = 1i64;
let Test.27 : Int1 = lowlevel Eq Test.25 Test.26;
if Test.27 then
let Test.10 : U64 = 0i64;
let Test.11 : Int1 = lowlevel ListGetUnsafe Test.1 Test.10;
dec Test.1;
let Test.12 : Int1 = false;
let Test.13 : Int1 = lowlevel Eq Test.12 Test.11;
if Test.13 then
let Test.5 : Str = "B";
ret Test.5;
else
jump Test.9;
else
let Test.22 : U64 = lowlevel ListLen Test.1;
let Test.23 : U64 = 2i64;
let Test.24 : Int1 = lowlevel NumGte Test.22 Test.23;
if Test.24 then
let Test.18 : U64 = 0i64;
let Test.19 : Int1 = lowlevel ListGetUnsafe Test.1 Test.18;
let Test.20 : Int1 = false;
let Test.21 : Int1 = lowlevel Eq Test.20 Test.19;
if Test.21 then
let Test.14 : U64 = 1i64;
let Test.15 : Int1 = lowlevel ListGetUnsafe Test.1 Test.14;
dec Test.1;
let Test.16 : Int1 = false;
let Test.17 : Int1 = lowlevel Eq Test.16 Test.15;
if Test.17 then
let Test.6 : Str = "C";
ret Test.6;
else
let Test.7 : Str = "D";
ret Test.7;
else
dec Test.1;
jump Test.9;
else
dec Test.1;
jump Test.9;