Commit graph

126 commits

Author SHA1 Message Date
Richard Feldman
c4497f2c1c
Remove Nat from Num 2024-01-26 16:19:51 -05:00
Folkert
6ab54c02e2
drop into_iter in some places 2023-10-07 19:11:36 +02:00
Richard Feldman
2da41be29f
Merge remote-tracking branch 'origin/main' into abilities-syntax 2023-08-10 20:36:01 -04:00
Ayaz Hafiz
d7a30966c1
Add explicit casts
For some reason these can no longer be inferred.
2023-07-17 09:50:37 -05:00
Ayaz Hafiz
8d1d4e6df3
debug import 2023-07-17 09:50:37 -05:00
Ayaz Hafiz
5ea9bd19b2
Unify on roots 2023-07-17 09:50:37 -05:00
Ayaz Hafiz
18e9f8f034
Move unify::Mode to roc_solve_schema 2023-07-17 09:50:36 -05:00
Ayaz Hafiz
87d108eccc
Push checkmate through env 2023-07-17 09:48:59 -05:00
Ayaz Hafiz
8097ee3342
Hide subs behind Env deref 2023-07-17 09:48:57 -05:00
Ayaz Hafiz
6e5a308557
Content variant ErasedLambda 2023-07-12 13:57:17 -05:00
Ayaz Hafiz
16ebcba053
Use index 2023-07-12 13:53:51 -05:00
Ayaz Hafiz
15ae7489a8
Unify erased lambda sets 2023-07-12 13:53:51 -05:00
Folkert
ef39bad7c6
auto clippy fixes 2023-07-10 18:27:08 +02:00
Ayaz Hafiz
49a92e5ef1
Support fixpoint-fixing under recursion variables
Sometimes, we might need to fixpoint-fix a unification like

[ Bar [ Bar <a>, Foo ], Foo ] as <a>  🛠️  [ Bar <b>, Foo ] as <b>

where we hit a comparison between <a> and <b>. In this case, follow each
recursion point independently and see if we can find the chain to the needle
we were searching for.

Closes #5476
2023-06-13 17:15:11 -05:00
Bryce Miller
dbc0204532
abilities syntax has -> implements 2023-05-24 21:30:16 -04:00
Ayaz Hafiz
8ca1e6c866
Correct occurs cycle under alias argument but not alias real var
At times we can have alias arguments that are recursive in their
position, but whose recursiveness is not immediately visible in the real
var.

Closes #5330
2023-05-02 17:00:58 -05:00
Ayaz Hafiz
8dc86a81b8
Rename ROC_VERIFY_OCCURS_RECURSION flag 2023-05-02 17:00:58 -05:00
Ayaz Hafiz
5815807927
seen_recursion_pair is immutable 2023-05-02 17:00:58 -05:00
Ayaz Hafiz
238e64c0b3
Defer resolution of a recursion variable during union unification until merging
While unifying two unions, we may turn one of them into a recursive
union. If we don't recognize the recursiveness before merging, we'll
have lost the recursive value of the union.
2023-05-01 13:14:59 -05:00
Ayaz Hafiz
5ec2715820
Correctly introduce new recursion variables at the correct rank 2023-05-01 13:14:59 -05:00
Folkert
394495d307 Revert "update size asserts"
This reverts commit 9973d4b8d2.
2023-04-21 13:22:23 +02:00
Folkert
4cd8f0a056 clippy --fix fixes 2023-04-21 12:05:51 +02:00
Ayaz Hafiz
e06eac9769
Be sure to unify recursion var structure if it hasn't been seen 2023-03-27 10:10:56 -05:00
Ayaz Hafiz
f7455deb06
Get rid of inaccurate debug assertion 2023-03-25 15:01:41 -05:00
Ayaz Hafiz
9b7c4bf367
Debug assertion should be negated 2023-03-25 15:01:40 -05:00
Brendan Hansknecht
4a89bee0a5
centralize package versions except for vendor and excluded 2023-03-06 19:29:09 -08:00
Brendan Hansknecht
5485c8a5b0
update to using workspace package spec 2023-03-06 16:36:18 -08:00
Brendan Hansknecht
21af20597e
remove unused dependencies 2023-03-06 12:09:00 -08:00
Ayaz Hafiz
d7a069675b
Lambda set compaction must preserve unique specializations of concrete types
There are times that multiple concrete types may appear in
unspecialized lambda sets that are being unified. The primary case is
during monomorphization, when unspecialized lambda sets join at the same
time that concrete types get instantiated. Since lambda set
specialization and compaction happens only after unifications are
complete, unifications that monomorphize can induce the above-described
situation.

In these cases,

- unspecialized lambda sets that are due to equivalent type variables
  can be compacted, since they are in fact the same specialization.
- unspecialized lambda sets that are due to different type variables
  cannot be compacted, even if their types unify, since they may point
  to different specializations. For example, consider the unspecialized
  lambda set `[[] + [A]:toEncoder:1 + [B]:toEncoder:1]` - this set wants
  two encoders, one for `[A]` and one for `[B]`, which is materially
  different from the set `[[] + [A, B]:toEncoder:1]`.
2023-02-20 18:50:07 -06:00
Ayaz
a7c415dc35
Merge pull request #4940 from joshuawarner32/tuple-solve
Initial implementation of tuples in type checking
2023-01-23 16:25:35 -06:00
Joshua Warner
de828416bf
Initial implementation of tuples in type checking
This leaves in place a bunch of TODOs and likely many bugs - notably, I haven't tested codegen/layout at all here.
2023-01-22 12:40:44 -08:00
Ayaz Hafiz
f6da8275ec
Record changed variables if any nested variable has changed
When we unify variables in mono, we must invalidate the sections of the
layout cache reached by those variables. Previously we did this by
recording changed variables as those that were `merge`d. However this is
not enough; we must also record all the parent types they came from. The
reason is we may have something like

```
Alias (Foo, a) ~ Alias (Bar, U8)
```

where we will merge `a = U8` but we do not merge the aliases.

Closes #4919
2023-01-21 12:37:21 -06:00
Ayaz Hafiz
20d0d62af7
Allow extending Openness constraints when doing specializations 2023-01-16 10:54:39 -06:00
Ayaz Hafiz
1d75934659
Don't match empty tag union in openness constraint 2023-01-16 10:54:39 -06:00
Ayaz Hafiz
91d61424ad
Lints 2023-01-16 10:54:39 -06:00
Ayaz Hafiz
2f74d0b1b9
Do not permit inferred-open-in-output-position extension variables to grow
Closes #4852
Closes #4845
2023-01-16 10:54:38 -06:00
Ayaz Hafiz
281b71cf94
Unification of Any and Openness tag extensions 2023-01-16 10:52:23 -06:00
Ayaz Hafiz
1c93727822
Add a notion of "openness" tag extensions suitable only for size-polymorphism 2023-01-16 10:52:23 -06:00
Ayaz Hafiz
1c58118dc7
Strip _new from tag unification functions 2023-01-16 10:52:22 -06:00
Joshua Warner
8abd5cf605
Fix bug in unification of tag args in polymorphic contexts 2022-12-26 13:01:31 -08:00
Joshua Warner
174f7d5e4d
Fix bug in unifying records
This was leading us to have an infinitely-recursive type, which eventually causes layout to stack-overflow

Fixes #4739
2022-12-17 11:37:19 -08:00
Ayaz Hafiz
63b0eb49d8
Explicit is_inside_lambda_set not needed 2022-12-13 09:00:46 -06:00
Ayaz Hafiz
79ee266f66
Snapshot/restore pool if lambda sets are disjoint 2022-12-12 18:06:50 -06:00
Ayaz Hafiz
0ef0638862
Remove more dead code 2022-12-12 15:48:30 -06:00
Ayaz Hafiz
22c8719eed
Dead code 2022-12-12 15:47:58 -06:00
Ayaz Hafiz
23932137ef
Avoid exponential unification paths
🤦 when we check whether lambdas can be unified or must be
treated as disjoint we previously had a code path that is actually
exponential in its runtime, regardless of whether it succeeds or fails.
Now, it is linear, though degraded (with a clone) if it fails.
2022-12-12 15:46:05 -06:00
Ayaz Hafiz
cd2b936a59
Ensure that disjoint nested lambda sets force parents to be disjoint
We must be careful to ensure that if unifying nested lambda sets
results in disjoint lambdas, that the parent lambda sets are
ultimately treated disjointly as well.
Consider

```
  v1: {} -[ foo ({} -[ bar Str ]-> {}) ]-> {}
~ v2: {} -[ foo ({} -[ bar U64 ]-> {}) ]-> {}
```

When considering unification of the nested sets

```
  [ bar Str ]
~ [ bar U64 ]
```

we should not unify these sets, even disjointly, because that would
ultimately lead us to unifying

```
v1 ~ v2
=> {} -[ foo ({} -[ bar Str, bar U64 ]-> {}) ] -> {}
```

which is quite wrong - we do not have a lambda `foo` that captures
either `bar captures: Str` or `bar captures: U64`, we have two
different lambdas `foo` that capture different `bars`. The target
unification is

```
v1 ~ v2
=> {} -[ foo ({} -[ bar Str ]-> {}),
         foo ({} -[ bar U64 ]-> {}) ] -> {}
```

Closes #4712
2022-12-12 14:51:18 -06:00
Ayaz Hafiz
0bae0aafb6
Unify ranged numbers with flex able, modulo obligation checking
Closes #4594
2022-12-01 09:50:29 -06:00
Ayaz Hafiz
e36618b9e9
Support custom abilities for opaques with immaterial lambda sets
If a specialization of an ability member has a lambda set that is not
reflected in the unspecialized lambda sets of the member's prototype
signature, then the specialization lambda set is deemed to be immaterial
to the specialization lambda set mapping, and we don't need to associate
it with a particular region from the prototype signature.

This can happen when an opaque contains functions that are some specific
than the generalized prototype signature; for example, when we are
defining a custom impl for an opaque with functions.

Addresses a bug found in 8c3158c3e0
2022-11-21 18:03:56 -06:00
Ayaz Hafiz
e1afd964c7
Correct when fixpoint-fixed type variables can be reunified
With fixpoint-fixing, we don't want to re-unify type variables that were
just fixed, because doing so may change their shapes in ways that we
explicitly just set them up not to be changed (as fixpoint-fixing
clobbers type variable contents).

However, this restriction need only apply when we re-unify two type
variables that were both involved in the same fixpoint-fixing cycle. If
we have a type variable T that was involved in fixpoint-fixing, and we
unify it with U that wasn't, we know that the $U \notin \bar{T}$, where
$\bar{T}$ is the recursive closure of T. In these cases, we do want to
permit the usual in-band unification of $T \sim U$.
2022-11-21 15:57:36 -06:00