Commit graph

133 commits

Author SHA1 Message Date
Ayaz Hafiz
b8712bcb30
Weaken records in let-bindings
This change also means we must update the interface of `Dict.empty` and
`Set.empty` from

```
Dict.empty : Dict k v
```

to

```
Dict.empty : {} -> Dict k v
```
2023-01-14 15:33:51 +01:00
Ayaz Hafiz
cb1373a3a4
Weaken let-binding calls 2023-01-14 15:33:49 +01:00
Ayaz Hafiz
b2cdddbdfb
Weaken lists 2023-01-12 10:02:20 -06:00
Folkert
cf15654ee5
implement standard as patterns in mono IR 2023-01-11 14:18:13 +01:00
Ayaz Hafiz
ba2527a020
Check in mono test case 2023-01-09 16:35:25 -06:00
Ayaz
858670fac7
Merge pull request #4833 from roc-lang/intern-layouts
Intern all the layouts
2022-12-29 18:28:44 -06:00
Ayaz Hafiz
3aab378bab
Correct pattern matching of nullable wrapped tag unions
The nullable ID always has zero tags. For everything else, we should
just match with the arity of the number of arguments, which doesn't
include the tag ID.
2022-12-29 12:22:05 -06:00
Ayaz Hafiz
dd6a72fc46
Update mono tests
These have changed because of how interned layouts are now sorted.
2022-12-28 18:50:50 -06:00
Ayaz
562a2748cb
Merge branch 'main' into i4732
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
2022-12-28 11:56:08 -06:00
Ayaz
b400851586
Merge branch 'main' into i4717
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
2022-12-27 18:58:16 -06:00
Ayaz Hafiz
23fc7f1413
Appropriately substitute symbols in switch conditions
Closes #4557
2022-12-27 12:29:23 -06:00
Ayaz Hafiz
a818b810f2
Better name for #4717 repro case 2022-12-27 11:05:12 -06:00
Ayaz Hafiz
7a6e68861c
Account for non-capturing functions in larger lambda sets passed to HOLLs
Previously, if the lambda set passed to a HOLL contained any function
that captured, we would assume that the specialization of the HOLL we
should make for each function in the lambda set that we dispatch to
should capture.

This is not right. Instead, we should specialize for each lambda in the
set passed to the HOLL. The present patch enforces that, making sure
that for each lambda in the set, we compute the exact proc layout needed
to call the lambda, based on the captures of the specific lambda in the
set, rather than looking at the set entirely.
2022-12-27 10:22:18 -06:00
Ayaz Hafiz
1e847efbfe
Correctly choose specialized shapes for anonymous closures 2022-12-27 09:18:41 -06:00
Joshua Warner
8abd5cf605
Fix bug in unification of tag args in polymorphic contexts 2022-12-26 13:01:31 -08:00
Ayaz Hafiz
ec0f1ce757
Update mono test name 2022-12-25 16:56:00 -06:00
Ayaz Hafiz
2a64b18c98
Update mono tests 2022-12-25 16:56:00 -06:00
Ayaz Hafiz
a8693e6102
Order list-min-size tests in descending order
Some of the head-constructor tests we generate can be supersets of other tests.
Edges must be ordered so that more general tests always happen after their
specialized variants.

For example, patterns

  [1, ..] -> ...
  [2, 1, ..] -> ...

may generate the edges

  ListLen(>=1) -> <rest>
  ListLen(>=2) -> <rest>

but evaluated in exactly this order, the second edge is never reachable.
The necessary ordering is

  ListLen(>=2) -> <rest>
  ListLen(>=1) -> <rest>

Closes #4732
2022-12-25 16:55:58 -06:00
Joshua Warner
174f7d5e4d
Fix bug in unifying records
This was leading us to have an infinitely-recursive type, which eventually causes layout to stack-overflow

Fixes #4739
2022-12-17 11:37:19 -08:00
Ayaz Hafiz
5606e2d61e
Update test 2022-12-14 17:15:51 -06:00
Ayaz Hafiz
0a071e2a98
Rename mono test 2022-12-14 17:13:58 -06:00
Ayaz Hafiz
b8aa8df100
Make sure to resolve lambda sets for imported top-levels correctly
Part of #4733
2022-12-14 17:13:43 -06:00
Ayaz Hafiz
ed4e047ee8
Reproduce #4733 2022-12-14 17:12:03 -06:00
Ayaz Hafiz
cec6da19de
Check in mono test 2022-12-14 14:20:10 -06:00
Richard Feldman
da5d0bd815
Merge pull request #4686 from roc-lang/list-range
Switch to more expressive list.range
2022-12-08 02:51:42 -05:00
Ayaz Hafiz
b66813d2db
Check in test for #4705 2022-12-07 10:59:05 -06:00
Ayaz
8ae8857125
Merge pull request #4696 from roc-lang/hash-nat
add the ability to hash Nats
2022-12-05 20:15:21 -06:00
Brendan Hansknecht
b07e4e8170
fix mono 2022-12-05 16:11:10 -08:00
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
Ayaz Hafiz
b6a96ebb85
Reproduce miscompilation in #4685 2022-12-05 13:14:32 -06:00
Brendan Hansknecht
415cac5179
update mono tests 2022-12-04 21:49:28 -08:00
Brendan Hansknecht
1dd0738eba
update mono test for dict again 2022-12-03 13:17:36 -08:00
Brendan Hansknecht
436bfc41ed
disable glue test and update mono test 2022-12-03 13:17:36 -08:00
Brendan Hansknecht
a321e36a36
update mono test for dict 2022-12-03 13:17:34 -08:00
Ayaz Hafiz
078f0147ee
Do not bind accessors in toplevel thunks to their thunks' names
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
2022-12-02 08:50:03 -06:00
Ayaz Hafiz
9181ed8092
Correctly compile rvalue closures defined in nested defines to lvalues
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
2022-12-01 15:47:18 -06:00
Ayaz Hafiz
68e364d897
Do not attempt to handle aliasing of procs in variable assignments
Please see the comment in the diff to explain the rationale of this
change.

Closes #4636
2022-12-01 15:20:58 -06:00
Ayaz Hafiz
cb7de132e5
Update mono 2022-11-24 14:46:54 -06:00
Ayaz Hafiz
7e975b9111
Update mono tests 2022-11-24 14:46:53 -06:00
Ayaz Hafiz
220c8a8e64
Add a crash test to mono 2022-11-24 14:46:51 -06:00
Richard Feldman
8dfdddbedc
Update mono...for some reason 2022-11-04 17:18:32 -04:00
Ayaz Hafiz
204ac2f8b4
Consolidate mono test behavior in debug and release modes
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
2022-11-02 15:04:47 -05:00
Ayaz Hafiz
822aa71a0a
Compute list element stores lazily 2022-11-01 15:37:36 -05:00
Ayaz Hafiz
27b9dd8253
Simplify arity and branching calculation 2022-11-01 15:33:23 -05:00
Ayaz Hafiz
45f7cd5ad7
Make sure to update path of matched list 2022-11-01 15:22:31 -05:00
Ayaz Hafiz
ae71c7efe2
Decision tree compilation of list patterns 2022-11-01 15:22:31 -05:00
Ayaz Hafiz
fda485431f
Update mono test 2022-09-21 13:41:20 -05:00
Ayaz Hafiz
2037ad22fd
Update encode mono test 2022-09-21 13:40:50 -05:00
Ayaz Hafiz
dc70c1b0b0
Update mono tests 2022-09-21 13:39:10 -05:00
Ayaz
211c297230
Merge pull request #4041 from KilianVounckx/opaque-bool
Opaque bool
2022-09-21 11:15:41 -05:00