Commit graph

409 commits

Author SHA1 Message Date
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
Ayaz Hafiz
0abfca401a
Update mono tests 2022-09-20 14:42:08 -05:00
kilianv
08c238ff27
Generate new files in test_mono after changing to opaque bools 2022-09-20 14:42:05 -05:00
kilianv
9717747a54
Update tests
not all tests pass yet. Will look at them with Ayaz.
2022-09-20 14:42:03 -05:00
Ayaz Hafiz
2f7020aa31
Eliminate voided branches only after resolving their bodies' specializations 2022-09-20 08:35:10 -05:00
Ayaz Hafiz
f41936d5e5
Unwrap layouts containing void layouts as newtypes
Addresses the attempt to do so in https://github.com/roc-lang/roc/pull/3465

Co-authored-by: Folkert <folkert@folkertdev.nl>
2022-09-19 16:50:49 -05:00
Ayaz Hafiz
be853b65c5
Support unification of extension types with uninhabited branches 2022-09-19 10:32:39 -05:00
Ayaz Hafiz
a81d4d4be2
Allow any numeric range to become a float
Currently things like `1 / 200` lead to a miscompilation because we type
`200` (and as a result, both `1` and the division result) as a ranged
number with width >= U8. During mono that forces the number to become an
`I64` because our logic was that a ranged number can only become a float
if it's at least as wide as an I8. But this is incorrect; as long as the
type is wrapped in `Frac` constructor and it's a ranged number (and not
a ranged int), it should become a fractional type.

```
» 1 / 200

0.005 : Float *
```

Closes #4047
2022-09-16 10:05:43 -05:00
Ayaz Hafiz
d8a8dff70d
Treat unwrapped capture sets as unwrapped directly 2022-08-19 22:16:41 -05:00
Ayaz Hafiz
68bb03ec09
Update mono tests 2022-08-19 22:16:41 -05:00
Ayaz Hafiz
fc4979e2ce
Add ClosureCallOptions enum to describe how to switch calling lambda 2022-08-19 22:16:40 -05:00
Richard Feldman
58c3575e44
Fix mono tests 2022-08-12 15:28:05 -04:00
Folkert
792936066c
Merge remote-tracking branch 'origin/trunk' into roc-std-platform 2022-08-07 13:28:03 +02:00
Richard Feldman
b0f7737227
Update mono tests 2022-08-03 22:45:38 -04:00
Ayaz Hafiz
fc9ff928eb
Choose non-recursion var when merging arbitrary variables, when possible.
Closes #3669
2022-08-02 08:15:54 -05:00
Ayaz Hafiz
1460f60ab1
Unify material recursion variables behind aliases and opaques
Even if there are no changes to alias arguments, and no new variables were
introduced, we may still need to unify the "actual types" of the alias or opaque!

The unification is not necessary from a types perspective (and in fact, we may want
to disable it for `roc check` later on), but it is necessary for the monomorphizer,
which expects identical types to be reflected in the same variable.

As a concrete example, consider the unification of two opaques

  P := [Zero, Succ P]

  (@P (Succ n)) ~ (@P (Succ o))

`P` has no arguments, and unification of the surface of `P` introduces nothing new.
But if we do not unify the types of `n` and `o`, which are recursion variables, they
will remain disjoint! Currently, the implication of this is that they will be seen
to have separate recursive memory layouts in the monomorphizer - which is no good
for our compilation model.

Closes #3653
2022-07-29 11:03:47 -04:00
Ayaz Hafiz
5df1dfae6f
Update mono tests 2022-07-25 11:44:48 -04:00
Ayaz Hafiz
5988257bde
Reflect newtypes in path instructions 2022-07-21 18:17:57 -04:00
Ayaz Hafiz
1acb7e0748
Don't add path instructions for newtypes that decay into their args 2022-07-21 14:57:17 -04:00
Ayaz Hafiz
0b74620a8f
Update mono tests 2022-07-18 22:15:22 -04:00
Ayaz Hafiz
17f53a23a5
Update tests 2022-07-18 17:55:02 -04:00
Ayaz Hafiz
9a66e936a8
Switch String deriving to be an immediate deriver 2022-07-15 10:39:08 -04:00
Folkert de Vries
460b822caa
Merge pull request #3501 from rtfeldman/derive-tag-union-encoding-gen
Derive tag union encoding gen
2022-07-15 15:57:41 +02:00
Folkert de Vries
1b1b63aad0
Merge branch 'trunk' into assoc-list-dict 2022-07-14 16:47:50 +02:00
Ayaz Hafiz
94ab904b6f
Fix compile errors 2022-07-14 09:02:37 -04:00