When we transform a top-level expect into an inline expect, we collect
all intermediate defs before the expect condition, then layer the defs
back on. Because the layering procedure builds an expression bottom-up,
we must layer on defs in reverse definition order.
Closes#4705
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
In #3352 an optimization to transform `ra = .field` into
```
ra = \#rcd -[ra]-> #rcd.field
```
rather than
```
__ra1 = \#rcd -[__ra1] -> #rcd.field
ra = LambdaSet { __ra1 }
```
was introduced. However, this optimization is not correct when `ra =
.field` is defined as a toplevel thunk, for in such situations we
indeed want the thunk `ra` to return the lambda set it resolves to,
rather than repointing at itself.
Besides reverting this change, another option would be to convert
accessors into closures before translation of Can to IR. However, this
complicates the translation algorithm more than it already is, and I'd
like to avoid additional special-cases.
Closes#4606
Previously, a program like
```
main =
f =
n = 1
\{} -[#lam]-> n # suppose lambda set = #lam
f {}
```
would be transformed to
```
main =
n = 1
f = \{} -[#lam]-> n
f {}
```
However, the IR lowering procedure is such that we would then associate
`f` as definining the procedure given the lambda set `#lam`. This is not
correct, as `f` is really a function pointer in this circumstance,
rather than the definer of `#lam`.
Instead, the transformation we want to perform is
```
main =
n = 1
#lam = \{} -[#lam]-> n
f = #lam
f {}
```
Which is what this patch does
Closes#2403
Makes sure that we turn on `debug-symbols` in mono tests, and that this
feature is fully respected in symbol generation, so that output in
release + debug builds are the same.
Closes#4435