Commit graph

126 commits

Author SHA1 Message Date
Ayaz Hafiz
25693f8ffe
Fix constraining 2022-11-24 14:46:50 -06:00
Ayaz Hafiz
e2b30e5301
Constrain + solve crash 2022-11-24 14:46:50 -06:00
Ayaz Hafiz
9dc489c2b0
First pass constraining crash 2022-11-24 14:46:49 -06:00
Ayaz Hafiz
b4216a26a5
Force occurs check for introduced types after checking annotated bodies
The current type inference scheme is such that we first introduce the
types for annotation functions, then check their bodies without
additional re-generalization. As part of generalization, we also perform
occurs checks to fix-up recursive tag unions.

However, type annotations can contain type inference variables that are
neither part of the generalization scheme, nor are re-generalized later
on, and in fact end up forming a closure of a recursive type. If we do
not catch and break such closures into recursive types, things go bad
soon after in later stages of the compiler.

To deal with this, re-introduce the values of recursive values after we
check their definitions, forcing an occurs check. This introduction is
benign because we already generalized appropriate type variables anyway.
Though, the introduction is somewhat unnecessary, and I have ideas on
how to make all of this simpler and more performant. That will come in
the future.
2022-11-24 10:05:28 -05:00
Ayaz Hafiz
5efdecafc9
Constrain flex inference variables without re-generalization
When constraining a recursive function like

```
f : _ -> {}
f : \_ -> f {}
```

our first step is to solve the value type of `f` relative to its
annotation. We have to be careful that the inference variable in the
signature of `f` is not generalized until after the body of `f` is
solved. Otherwise, we end up admitting polymorphic recursion.
2022-11-24 10:05:25 -05:00
Folkert
e44a8a9eed
print all the relevant info 2022-11-23 22:58:58 +01:00
Folkert
e7f3c6f281
inline dbg 2022-11-23 21:23:28 +01:00
Folkert
dcb530d3af
Revert "toplevel debug"
This reverts commit 5ea8d96f3e.
2022-11-23 20:29:55 +01:00
Folkert
5ea8d96f3e
toplevel debug 2022-11-23 20:29:45 +01:00
Ayaz Hafiz
60178f14e4
Remove redundant signature index 2022-11-16 14:05:50 -06:00
Ayaz Hafiz
b30e8fc9b2
Remove Cells from Types 2022-11-15 09:00:16 -06:00
Ayaz Hafiz
a52e9d605d
Remove unneeded type storage in constraining 2022-11-14 15:15:21 -06:00
Ayaz Hafiz
5564796927
SoA Types get variable emplacement (!)
We're now reaching the steady state we want to be closert to - when a
type is translated to a variable, emplace the variable we created for it
in the type index, so that types are never converted again!
2022-11-14 15:15:19 -06:00
Ayaz Hafiz
bf1b688afb
Eliminate indirect reference 2022-11-11 21:16:27 -06:00
Ayaz Hafiz
b03a1d3efd
eliminate type 2022-11-11 21:16:27 -06:00
Ayaz Hafiz
689fc10308
Use variable instead of type 2022-11-11 21:16:26 -06:00
Ayaz Hafiz
721c4cb1e6
Use variable instead of type 2022-11-11 21:16:26 -06:00
Ayaz Hafiz
d416b8b184
Do not clone return type 2022-11-11 21:16:26 -06:00
Ayaz Hafiz
bd9c9cc184
Replace busted gen test with reporting test 2022-11-11 21:16:26 -06:00
Ayaz Hafiz
3897c46a7b
Do not clone signature 2022-11-11 21:16:26 -06:00
Ayaz Hafiz
de17bab87c
Do not clone signature 2022-11-11 21:16:25 -06:00
Ayaz Hafiz
410413aa96
Do not clone return type 2022-11-11 21:16:25 -06:00
Ayaz Hafiz
8107c30a4b
Coalesce instantiated type indices 2022-11-11 21:16:25 -06:00
Ayaz Hafiz
764cc4d1d8
Do not clone annotation type 2022-11-11 21:16:25 -06:00
Ayaz Hafiz
cf1982733e
Do not clone signature closure type 2022-11-11 21:16:25 -06:00
Ayaz Hafiz
1ab8742d71
Do not clone return type 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
16f622b0df
Eliminate clone of signature 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
75ad2ffede
Do not clone signature closure type 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
b0be1ed08e
Do not clone return type 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
9e09914be2
Remove unused functions 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
02d3c73d9c
Mark internal functions as pub(crate) 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
c66a0f53c6
Remove str_type 2022-11-11 21:16:24 -06:00
Ayaz Hafiz
f1180a1549
Byte deletion party 2022-11-11 21:16:23 -06:00
Ayaz Hafiz
6b5f632364
[skip-ci] Fix borrow issues in constraining 2022-11-11 21:16:22 -06:00
Ayaz Hafiz
59d2de5a55
Constrain with Types SoA, sans borrow checker 2022-11-11 21:16:05 -06:00
Ayaz
8179e29bf8
Merge pull request #4486 from roc-lang/more-prep-constraining
Lift constraining expectation indices up a level
2022-11-08 13:47:57 -06:00
Ayaz Hafiz
51d813dae2
Index into constraining via trait 2022-11-08 09:00:51 -06:00
Ayaz Hafiz
24b6d4a3a9
constrain_pattern takes an expected index 2022-11-08 09:00:51 -06:00
Ayaz Hafiz
b85465d74d
Resolve runtime error todo 2022-11-08 09:00:51 -06:00
Ayaz Hafiz
f0534fc770
Remove TODO comment 2022-11-08 09:00:51 -06:00
Ayaz Hafiz
b71fef5f3b
Resolve ability member todo 2022-11-08 09:00:51 -06:00
Ayaz Hafiz
c76a928ed4
Remove var storage TODO 2022-11-08 09:00:51 -06:00
Ayaz Hafiz
4f40d83b80
Remove _inner migration helper 2022-11-08 09:00:50 -06:00
Ayaz Hafiz
d84e98751e
Always feed ExpectedTypeIndex to expr constraining 2022-11-08 09:00:50 -06:00
Ayaz Hafiz
4e2eb67ff1
Surface constrain_expr takes an index 2022-11-08 09:00:50 -06:00
Luke Boswell
a3f901427a
correct formatting and removed duplicate image 2022-11-03 20:02:10 +11:00
Luke Boswell
f3bdb5f321
updating rust package documentation 2022-11-03 20:00:06 +11:00
Ayaz Hafiz
a9bdbc968f
Fix constraining 2022-11-02 15:08:10 -05:00
Ayaz Hafiz
d811fa8e5a
Decloning party 2022-11-02 15:06:03 -05:00
Ayaz Hafiz
5ea9b145f6
More coalescing 2022-11-02 15:05:43 -05:00