Commit graph

145 commits

Author SHA1 Message Date
Ayaz Hafiz
d27a72de1f
Weaken let sequences under let binding 2023-01-14 15:33:49 +01:00
Ayaz Hafiz
e36f90feec
Weaken recursive let bindings 2023-01-14 15:33:49 +01:00
Ayaz Hafiz
2e41b59af4
Format 2023-01-12 10:02:21 -06:00
Ayaz Hafiz
04cf7e070d
Weaken let-bindings to if expressions 2023-01-12 10:02:21 -06:00
Ayaz Hafiz
9462f44bb7
Weaken variables bound to when expressions 2023-01-12 10:02:21 -06:00
Ayaz Hafiz
a2f04d1fa3
Weaken single quotes 2023-01-12 10:02:21 -06:00
Ayaz Hafiz
b2cdddbdfb
Weaken lists 2023-01-12 10:02:20 -06:00
Ayaz Hafiz
caa3a6c6a8
Weaken strings 2023-01-12 10:01:56 -06:00
Ayaz Hafiz
173d070175
Weaken expects 2023-01-12 10:01:56 -06:00
Ayaz Hafiz
31f3caef74
stand by Kawhi being the best 2023-01-11 14:30:38 -06:00
Ayaz Hafiz
058644aa96
Implement weakening of variables introduced in branch patterns
Variables introduced in branch patterns should never be generalized in
the new weakening model. This implements that. The strategy is:

- when we have a let-binding that should be weakened, do not introduce
  its bound variables in a new (higher) rank
- instead, introduce them at the current rank, and also solve the
  let-binding at the current rank
- if any of those variables should then be generalized relative to the
  current rank, they will be so when the current rank is popped and
  generalized
2023-01-11 14:28:46 -06:00
Ayaz Hafiz
5db82ad965
Explain why we currently cannot mark degeneralization in when headers 2023-01-11 14:28:46 -06:00
Ayaz Hafiz
cb18291aa8
Loosen weakening restriction for now 2023-01-11 14:28:45 -06:00
Ayaz
7c61d0d278
Merge pull request #4843 from roc-lang/pattern-as-can
Pattern as can
2023-01-08 19:36:40 -06:00
Folkert
c2ddeb0de0
fix and test as pattern type inference 2023-01-08 16:40:03 +01:00
Folkert
57f2233278
cleanup 2023-01-08 15:47:56 +01:00
Ayaz Hafiz
bcfb258db8
Add a bit to mark syntactically-generalizable types 2023-01-04 17:02:20 -06:00
Folkert
905341d849
can for normal (no-list) as 2022-12-31 15:46:11 +01:00
Ayaz Hafiz
bd06714fd2
Make sure to constrain dbgs with existential correctly 2022-12-14 17:02:29 -06:00
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