Commit graph

59 commits

Author SHA1 Message Date
Ayaz Hafiz
6bcd682dde
Support captures between mutually recursive closures 2022-08-13 10:25:18 -07:00
Ayaz Hafiz
e97ce32b88
Fixup transient closure captures during canonicalization
Closure captures can be transient, but previously, we did not handle
that correctly. For example, in

```
x = ""
inner = \{} -> x
outer = \{} -> inner {}
```

`outer` captures `inner`, but `inner` captures `x`, and in the body of
`outer`, we would not construct the closure data for `inner` correctly
before calling it.

There are a couple ways around this.

1. Update mono to do something when we are passed the captured
   environment of a closure, rather than attempting to construct a
   call-by-name's captured environment before callign it.
2. Fix-up closures during canonicalization to remove captured closures
   that themselves capture, and replace them with their captures.

This patch does (2), since (1) is much more involved and is not likely
to bring a lot of wins. In general I think it's reasonable to expect
captured environments, even if transient, to be fairly shallow, so I
don't think this will produce very large closure environments.

Closes #2894
2022-08-13 10:25:17 -07:00
Richard Feldman
97e2900bf5
s/rtfeldman/roc-lang/g in links to GitHub repos 2022-08-12 15:24:09 -04:00
Folkert de Vries
0798f787c5
Merge pull request #3736 from rtfeldman/i3687
Creation of a record whose type has an optional value is an error
2022-08-11 15:51:41 +02:00
Ayaz Hafiz
a1445c25bd
Update solve test 2022-08-10 20:24:20 -07:00
Ayaz Hafiz
40c73b4138
Add more names 2022-08-09 18:13:25 -07:00
Ayaz Hafiz
e1fb21fc59
Reproduce recursive lambda set inference 2022-08-09 14:09:57 -07:00
Ayaz Hafiz
6ebb0bfa6d
Fix solve tests 2022-08-02 16:15:35 -05:00
Folkert de Vries
86a1a0f401
Merge pull request #3643 from rtfeldman/disjoint-able-variable-specialization
Disjoint able variable specialization algorithm
2022-08-02 20:31:47 +02:00
Folkert de Vries
5061a67534
Merge pull request #3642 from rtfeldman/can-abilities6
Syntactic abilities: Part 6 - eager lambda set specialization, and fix ability let-generalization
2022-08-01 23:57:56 +02:00
Ayaz Hafiz
02d5d0ec92
Allow naming type variables with a basis hint
I think this makes it easier to read type variables when they come from
flex/rigid vars with pre-existing names, just give them a number suffix
to differentiate them.
2022-07-29 15:32:44 -04:00
Ayaz Hafiz
4657a957f7
When storing variables, merge them directly with the target rather than unifying
When we unify two variables that end up merged, the rank of the
resulting content is the lower of the two variables being merged. But
during storage, we really do mean, take the target descriptor of the
type we're merging against, and don't try to lower to a
possibly-generalized rank! This fixes a couple bugs I didn't even
realize were present!
2022-07-29 14:53:14 -04:00
Ayaz Hafiz
3b38228c36
Fix infer query indentation 2022-07-29 14:18:47 -04:00
Ayaz Hafiz
ff4b5f58ab
Avoid over-eager disjoint variable merging during lambda set compaction
During the unspecialized lambda set compaction procedure, we might end
up trying to merge too many disjoint variables during unspecialized
lambda unification. Avoid doing so, by checking if we're in the
compaction procedure.
2022-07-29 14:18:47 -04:00
Ayaz Hafiz
7926499900
Implement disjoint type variable handling in the lambda set specialization algorithm
This completes the last known hole I am aware of in the current
lambda set specialization algorithm.

Closes #3421
2022-07-29 14:18:46 -04:00
Ayaz Hafiz
1976e435a0
Turn a couple more solve tests back on 2022-07-29 08:43:19 -04:00
Ayaz Hafiz
41eb3ad9a4
Separate ability members and their specializations in reference checking 2022-07-29 08:43:19 -04:00
Ayaz Hafiz
f145f29b1b
Make sure records don't de-generalize function types, fixing ability let-generalization
Closes #3641
2022-07-29 08:43:19 -04:00
Ayaz Hafiz
ce8c8f7264
Update solve test
Use named recursive calls for now in ability members
2022-07-29 08:43:18 -04:00
Ayaz Hafiz
0989b2cb82
Move solve problems to their own crate 2022-07-28 08:57:32 -04:00
Ayaz Hafiz
28c1a4cb95
Use ImplKey in abilities store public API 2022-07-26 20:46:33 -04:00
Ayaz Hafiz
9a60f720d4
Add reproduction for recursive ability impl specialization with inference 2022-07-25 10:53:29 -04:00
Ayaz Hafiz
75ce40c67d
Make sure ability defs that are possibly recursive are marked as such 2022-07-25 10:52:55 -04:00
Ayaz Hafiz
cd0b8577ab
Have load_internal deal with separate declared/known ability specializations 2022-07-25 09:24:58 -04:00
Ayaz Hafiz
e2454f497f
Store declared implementations, both custom and derived, in abilities store 2022-07-25 09:09:01 -04:00
Ayaz Hafiz
c882c76685
Update test 2022-07-24 16:12:47 -04:00
Ayaz Hafiz
beccc92c87
Support underscores in assignment patterns 2022-07-24 16:11:03 -04:00
Ayaz Hafiz
d4cf9b8f8d
Apply is-open constraints to nested types
Closes #3459
2022-07-22 12:57:27 -04:00
Ayaz Hafiz
13b0ce7ca0
Make sure to apply "is-open" constraints at the very end of pattern constraining
Closes #3298
2022-07-22 12:57:27 -04:00
Ayaz Hafiz
613606a67d
Support inference options in solve tests 2022-07-22 12:57:26 -04:00
Ayaz Hafiz
7fbdbca4c6
Add multi-branch bound pattern solve test 2022-07-21 12:22:27 -04:00
Ayaz Hafiz
78dc82867a
Report errors for identifiers not bound in all patterns of a branch 2022-07-21 12:15:05 -04:00
Ayaz Hafiz
ce8b50caea
Support bound variables in multiple patterns 2022-07-21 11:40:09 -04:00
Ayaz Hafiz
bf8fc0d0de
Permit binding variables multiple itmes in when branches 2022-07-21 11:06:40 -04:00
Ayaz Hafiz
b4f45215ea
Fix solve tests 2022-07-19 15:02:52 -04:00
Ayaz Hafiz
d2da395619
Syntactic ability links in solve 2022-07-18 18:33:28 -04:00
Ayaz Hafiz
4d0c1e6a9c
Use insta for inferred queried tests 2022-07-18 17:55:02 -04:00
Ayaz Hafiz
17f53a23a5
Update tests 2022-07-18 17:55:02 -04:00
Richard Feldman
518b21c3f8
Rename Json.format to Json.toUtf8 2022-07-17 15:21:27 -04:00
Ayaz Hafiz
f1a6ea6a40
Typecheck and compile opaque wrapping functions
This enables you to write something like

```
A := U8
List.map [1, 2, 3] @A
```

which will be compiled as if it was `List.map [1, 2, 3] \x -> @A x`.

Closes #3499
2022-07-12 18:38:03 -04:00
Folkert de Vries
f1aae6f480
Merge pull request #3476 from rtfeldman/i3469
Remove more builtins code
2022-07-10 23:06:50 +02:00
Ayaz Hafiz
c211ec9790
Don't include DelayedAlias in illegal cycle checks 2022-07-10 13:53:41 -04:00
Ayaz Hafiz
98287e7670
Remove imported_builtins from load 2022-07-10 10:41:06 -04:00
Richard Feldman
c45e3ec4b4
Merge remote-tracking branch 'origin/trunk' into fix-nested-imports 2022-07-10 08:52:38 -04:00
Ayaz
7b308d9efe
Merge pull request #3404 from rtfeldman/ambient-lset-specialization
The ambient lambda set specialization algorithm
2022-07-09 17:23:27 -05:00
Richard Feldman
f45e3dbb46
Fix tests 2022-07-08 18:16:08 -04:00
Ayaz Hafiz
808d19b01b
Correctly compile unified recursive tag unions 2022-07-08 17:35:14 -04:00
Ayaz Hafiz
d9edb4d1bb
Support unification of recursion vars in opaques 2022-07-08 15:31:29 -04:00
Ayaz Hafiz
ebcd323449
Use strict unification of vars in unspecialized lambda sets right now 2022-07-06 13:08:58 -04:00
Ayaz Hafiz
0b427646e4
Continued progress on new lambda set compaction algorithm 2022-07-06 13:08:57 -04:00