Commit graph

162 commits

Author SHA1 Message Date
Ayaz Hafiz
b735188542
Life is short, no need to spell it out 2022-11-08 09:00:25 -06:00
Ayaz Hafiz
e240b18b27
Recover Erroneous in type 2022-11-08 09:00:25 -06:00
Ayaz Hafiz
58020a55d6
Type to variable through Types SoA 2022-11-08 09:00:24 -06:00
Ayaz Hafiz
dad9a8e537
Pass Types SoA repr in types to Variable translation 2022-11-08 09:00:24 -06:00
Ayaz Hafiz
34cd1fb825
Pattern expectation takes a type index 2022-11-02 15:05:40 -05:00
Ayaz Hafiz
2a4fca7034
First pass at expectations taking a type index 2022-11-02 15:05:22 -05:00
Ayaz Hafiz
6dc6386f77
DefTypes store slices into type indeces 2022-11-02 15:05:01 -05:00
Ayaz Hafiz
99a4e21618
Improve exhaustiveness checking heuristics for list patterns 2022-11-01 12:07:00 -05:00
Ayaz Hafiz
fbdf76e490
Report type errors in list pattern matches 2022-11-01 12:06:59 -05:00
Ayaz Hafiz
5e891a3501
Add comment on when heuristic can be removed 2022-10-31 09:48:25 -05:00
Ayaz Hafiz
debe6332c5
Support OIOP for type aliases 2022-10-31 09:38:21 -05:00
Ayaz Hafiz
bb1f4cd5e8
Fix bug in closing heuristic 2022-10-31 09:37:40 -05:00
Ayaz Hafiz
7b9ce492c3
Better estimate polarity in exhaustiveness checking 2022-10-31 09:37:40 -05:00
Ayaz Hafiz
69114cc820
Apply a heuristic for opening/closing types before exhaustiveness checking 2022-10-31 09:37:40 -05:00
Ayaz Hafiz
4d48ea7c2f
Materialize extension variable polarity in error type reporting 2022-10-31 09:37:40 -05:00
Folkert de Vries
02a76bb8bd
Merge pull request #4399 from roc-lang/no-types-in-constraining-api
Have most constraining APIs take a type index rather than `Type`
2022-10-26 19:45:55 +02:00
Ayaz
316ae7d30b
Merge pull request #4398 from roc-lang/emplace-type-variables
Leave variables behind when converting `Type`s to variables
2022-10-26 12:41:55 -05:00
Ayaz Hafiz
a4d7ee33c1
Apply lints 2022-10-24 18:23:36 -05:00
Ayaz Hafiz
97d47cc05f
includes_tag expects type index 2022-10-24 18:08:45 -05:00
Ayaz Hafiz
0642952d05
Remove some resolved todos 2022-10-24 14:00:46 -05:00
Ayaz Hafiz
66e75b8660
Simplify instantiation of bound able variables in non-delayed aliases 2022-10-24 14:00:46 -05:00
Ayaz Hafiz
3f5a86ded3
Update ability bindings 2022-10-24 14:00:46 -05:00
Ayaz Hafiz
1e6181d2cb
New data structure for storing sorted abilities bound to a variable 2022-10-24 13:59:51 -05:00
Ayaz Hafiz
229548571b
Represent "able" variables with slices of abilities 2022-10-24 13:59:51 -05:00
Ayaz Hafiz
0f0678ce73
s/closure_names/symbol_names/g in subs 2022-10-24 13:59:51 -05:00
Ayaz Hafiz
6bb97c92b9
Canonicalize multiple abilities bound to a type variable 2022-10-24 13:56:07 -05:00
Ayaz Hafiz
35a4781045
Get rid of redundant references 2022-10-24 13:13:08 -05:00
Ayaz Hafiz
9b24205906
Emplace variables made from types in expectations 2022-10-24 13:11:35 -05:00
Ayaz Hafiz
04a3f1c00e
Use a helper to emplace type cells 2022-10-24 12:07:00 -05:00
Ayaz Hafiz
d3e14550d8
Leave variables behind when converting Types to variables
This is part one of addressing the present issues with emplacing type
directly where type variables should be reused. Now, when an
`Index<Type>` is converted to a variable in solving, we leave the
converted variable in the `Type`'s place. Specifically, we keep an index
to a `Cell<Type>`.

Note that this transformation is only temporary, it will be removed once
we merge this with the `Type` SoA representation, but it is needed in
the meantime as I transform the `Constrain` API to get rid of
type-emplacement.
2022-10-24 11:42:35 -05:00
Ayaz Hafiz
05e8e6de6f
Disallow typing optional fields when required fields are annotated
Closes #4313
2022-10-18 15:50:20 -05:00
Ayaz Hafiz
5e35b6458a
Apply lint suggestions 2022-10-14 13:56:01 -05:00
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