Commit graph

180 commits

Author SHA1 Message Date
Ayaz Hafiz
65f1bd2907
Fix rigid able bindings to abilities 2022-10-14 13:56:01 -05:00
Ayaz Hafiz
20e4295eea
Make sure type variables bound to abilities are instantiated in aliases
Closes #4259
2022-10-14 13:56:00 -05:00
Richard Feldman
3d5728d82c
Merge pull request #4257 from roc-lang/i4246
Correctly check mutual functional recursion between opaque types
2022-10-08 16:20:27 -07:00
Ayaz Hafiz
d9863cbbaa
Correctly check mutual functional recursion between opaque types
The mutual-recursion checks does not admit types that are not function
types; because Roc is strict, only functional values can be involved in
mutual recursion. However, this check was exercised by checking the head
constructor of a type, which is not the correct way to do it. Aliases
and opaque types may in fact be function types as well, so we must chase
their actual contents.

Closes #4246
2022-10-08 10:09:55 -05:00
Ayaz Hafiz
61cf8e53e6
Have FunctionOrTagUnion include multiple possible tags 2022-10-05 17:24:52 -05:00
Folkert de Vries
cc202a4cf9
Merge pull request #4082 from roc-lang/update-cli-platform-unreachables
Support unification with uninhabited tag variants in more places
2022-09-21 12:18:38 +02:00
Ayaz Hafiz
f96c825aa4
Allow uninhabited type extension to happen on either unification side 2022-09-20 14:20:47 -05:00
Ayaz Hafiz
b0598ef817
Simplify unification with uninhabited tags to happen anytime tags are uninhabited
I believe this is safe! No need to gate it behind a mode.
2022-09-20 14:13:55 -05:00
Ayaz Hafiz
1799d6ed0e
Construct exhaustiveness branches with condition, not branch, variable
Previously we would construct the shapes of unions used in the pattern
tree for exhaustiveness checking using the type of the branch patterns,
rather than the type of the condition variable. Clearly we want to
always use the condition variable, otherwise some branches will be
seen as exhaustive, when they are not!

To do this, we now index into the condition variable while refying the
patterns to build the tree for exhaustiveness checking.

Closes #4068
2022-09-19 13:37:59 -05:00
Ayaz Hafiz
be853b65c5
Support unification of extension types with uninhabited branches 2022-09-19 10:32:39 -05:00
Ayaz Hafiz
c2452ff751
Lose rigidity of annotated optional fields before generalization
We have this idea of "rigid optional" fields to annotate record fields
that must necessarily be optional. That avoids the admission of programs
we cannot faithfully compile, like

```
f : {a: Str, b ? U64}
f = {a: "b", b: 1}
```

We want to lose the rigidity restriction when a generalized symbol is
used as at a specialized site; for example it should be possible to call
`f : {x ? Str} -> {}` with both `{}` and `{x : Str}`, neither of which
have a rigidly optional field unless they were to be annotated.

Prior to this commit we would loosen the rigidity restriction upon
specialization of a generalized type at a use site. However, what we
really want to do is apply the loosening during calculation of
generalization. The reason is that otherwise, we must make types that
would be ground (like `{x ? Str} -> {}`) generalized just for the sake
of the optional field annotation. But since the rigidity constraint is
irrelevant after an annotated body has been checked, we can loosen the
rigidity restriction then, which conveniently happens to coincide with
the generalization calculation.

Closes #3955
2022-09-06 17:44:04 -05: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
81bb889e93
Add RigidOptional record field variant 2022-08-10 20:24:18 -07:00
Ayaz Hafiz
bfd49299e0
Clippy 2022-08-09 17:45:52 -07:00
Ayaz Hafiz
3f1e11f920
Recursive vars in occurs check can happen anywhere in the chain 2022-08-09 16:07:59 -07:00
Ayaz Hafiz
d22bd274fd
Check for infinite types of introduced variables before bodies 2022-08-09 14:09:51 -07: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
7a4c57d3dc
Clippy 2022-07-29 08:43:19 -04:00
Ayaz Hafiz
4049eb6780
Remove unused OpportunisticResolve field 2022-07-29 08:43:19 -04:00
Ayaz Hafiz
31220d5598
Fix spelling 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
f2d4bf20ba
Collect awaited lambda set specializations to be solved when a specialization is known
Despite our best efforts, sometimes we still can't specialize lambda
sets on the fly, if a specialization lambda set's specialization type
isn't yet well-known! This commit adds an `AwaitingSpecializations`
data structure to keep track of the lambda sets blocked for
specialization behind a specialization's full resolution in the module.
After the specialization is resolved, its blocked lambda sets can be
eagerly compacted.
2022-07-29 08:43:18 -04:00
Ayaz Hafiz
350d9cd59b
Simplify opportunistic resolution
We don't need to unify the type state anymore because resolved able
variables are determined only by one type variable.
2022-07-29 08:43:18 -04:00
Ayaz Hafiz
76fe397aa1
Consolidate exposed types and derived module in a derived environment 2022-07-29 08:43:17 -04:00
Ayaz Hafiz
0ec92c12f7
Move lambda set specialization to its own module in solve 2022-07-29 08:43:16 -04:00
Ayaz Hafiz
c0e976f544
Wrap unification subs in Env 2022-07-28 08:57:33 -04:00
Ayaz Hafiz
0989b2cb82
Move solve problems to their own crate 2022-07-28 08:57:32 -04:00
Ayaz Hafiz
753d12e912
Eagerly resolve obligations during solving
Replaces the previously-used `DeferredObligations` structure used for
accumulating and then acting over ability obligations during module
solving in favor of just the `ObligationCache`. The `ObligationCache`
stays alive for the entirety of a module solving and provides a
convenient mechanism for answering obligation queries with a backed
cache.
2022-07-28 08:57:13 -04:00
Ayaz Hafiz
8659ddc684
Remove dominated derive errors 2022-07-26 20:46:35 -04:00
Ayaz Hafiz
ad3eb959e9
Don't mark dominated derives anymore 2022-07-26 20:46:34 -04:00
Ayaz Hafiz
04ee74542d
Rename IncompleteAbility 2022-07-26 20:46:34 -04:00
Ayaz Hafiz
c0d26226dd
Remove deferred obligation for opaques during solving 2022-07-26 20:46:34 -04:00
Ayaz Hafiz
c1dbffdad9
Make sure wrong specializations become error types 2022-07-26 20:46:34 -04:00
Ayaz Hafiz
3703940da9
Report specializations that target the unexpected type 2022-07-26 20:46:34 -04:00
Ayaz Hafiz
f2cf7405df
Revert "Use abilities ImplKey in solve"
This reverts commit b7cb0003134f1b0c657d7173db6965b4247500aa.
2022-07-26 20:46:33 -04:00
Ayaz Hafiz
254d684dfa
Use abilities ImplKey in solve 2022-07-26 20:46:33 -04:00
Ayaz Hafiz
28c1a4cb95
Use ImplKey in abilities store public API 2022-07-26 20:46:33 -04:00
Ayaz Hafiz
51bce825fb
Properly record all erroring ability implementations 2022-07-25 11:30:03 -04:00
Ayaz Hafiz
e2454f497f
Store declared implementations, both custom and derived, in abilities store 2022-07-25 09:09:01 -04:00
Folkert de Vries
860df057dc
Merge pull request #3600 from rtfeldman/i3298
Various improvements to is-open constraints/catch-all branches in patterns
2022-07-23 12:49:35 +02:00
Ayaz Hafiz
5ad04dcd2c
Emit runtime error when tag unions have an error type
Closes #3266
2022-07-22 15:46:09 -04:00
Ayaz Hafiz
d4cf9b8f8d
Apply is-open constraints to nested types
Closes #3459
2022-07-22 12:57:27 -04:00
Folkert de Vries
ca38ec4eb5
Merge pull request #3541 from rtfeldman/rocasync
Changes to get roc-async working
2022-07-18 19:22:07 +02:00
Ayaz Hafiz
eb2012dcad
Typos 2022-07-15 10:39:10 -04:00
Ayaz Hafiz
7b23077265
Treat numbers as ad-hoc types for the purpose of checking ability obligations 2022-07-15 10:39:09 -04:00
Ayaz Hafiz
c98ba441cf
Properly handle immediate derivations 2022-07-15 10:38:11 -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
Ayaz Hafiz
161c2101a7
Properly link lambda set variables in host exposed aliases 2022-07-14 12:20:39 -04:00
Folkert de Vries
1b1b63aad0
Merge branch 'trunk' into assoc-list-dict 2022-07-14 16:47:50 +02:00