Commit graph

87 commits

Author SHA1 Message Date
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
Ayaz Hafiz
76a3e92088
Fix debug flags for release mode 2022-11-16 14:05:53 -06:00
Ayaz Hafiz
a8b55dc794
Admit occurs check under recursive tag unions when programs have type errors 2022-11-16 14:05:53 -06:00
Ayaz Hafiz
735685dd86
Include error vars in is_recursion_var checks 2022-11-16 14:05:53 -06:00
Ayaz Hafiz
bef9b54124
Avoid parsing doc comments as code 2022-11-16 14:05:53 -06:00
Ayaz Hafiz
2cba520839
Document fixpoint fixing algorithm 2022-11-16 14:05:51 -06:00
Ayaz Hafiz
8414c8e2de
Remove unneeded comments 2022-11-16 14:05:51 -06:00
Ayaz Hafiz
5a92947326
Use fixpoint-fixing in unification 2022-11-16 14:05:51 -06:00
Ayaz Hafiz
3c968b581d
Check in fixpoint-fixing algorithm 2022-11-16 14:05:51 -06:00
Ayaz Hafiz
fb643758bb
Remove Unified BadType 2022-11-08 14:11:25 -06:00
Ayaz Hafiz
09748aec48
Remove problems from error type API surface 2022-11-08 14:11:25 -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
a58d128d9e
Cover mode when unifying variable slices 2022-11-01 12:06:59 -05:00
Ayaz Hafiz
debe6332c5
Support OIOP for type aliases 2022-10-31 09:38:21 -05:00
Ayaz Hafiz
f3623b1e47
Close extension types extended wiht uninhabited types after their extension 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
Ayaz Hafiz
c0257302a9
Address clippy lints 2022-10-24 14:00:45 -05:00
Ayaz Hafiz
3bd10698cf
Allow rigid able to unify with flex able when rigid bounds are a superset 2022-10-24 14:00:45 -05:00
Ayaz Hafiz
9c88534758
Obligation checking layers on extra abilities bound to a variable 2022-10-24 13:59:52 -05:00
Ayaz Hafiz
db7fe48d1c
Merge muliple abilities bound to flex var 2022-10-24 13:59:52 -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
05e8e6de6f
Disallow typing optional fields when required fields are annotated
Closes #4313
2022-10-18 15:50:20 -05:00
Ayaz Hafiz
81fa0407b6
Satiate must_use reason 2022-10-12 16:38:36 -05:00
Ayaz Hafiz
f3a6b45452
Add must_use to all unification results
Making sure that no unspecialized lambda sets slip through the cracks!
2022-10-12 16:37:50 -05:00
Ayaz
83b64c4fb3
Merge pull request #4209 from roc-lang/impl-tag-discriminant
Derive `Hash` implementations for tag unions
2022-10-10 22:23:05 -05:00
Ayaz Hafiz
16f43f5768
Clippy 2022-10-05 17:25:12 -05:00
Ayaz Hafiz
06e5110aa5
Unification of multiple tag-functions 2022-10-05 17:25:11 -05:00
Ayaz Hafiz
61cf8e53e6
Have FunctionOrTagUnion include multiple possible tags 2022-10-05 17:24:52 -05:00
Ayaz Hafiz
2517695ce4
Fix deriving of hash ability for recursive tag unions 2022-10-05 12:01:02 -05:00
Ayaz Hafiz
294244ae25
Make sure flex unifies with rigid-able vars correctly 2022-10-04 14:09:40 -05: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
be853b65c5
Support unification of extension types with uninhabited branches 2022-09-19 10:32:39 -05:00
Ayaz Hafiz
086f7a7e9d
Attempt occurs checks for recursive lambda sets only during monomorphization 2022-08-31 16:45:57 -05:00
Ayaz Hafiz
ea2e5d171a
Invalidate layout-cached variables correctly after merging 2022-08-31 14:17:14 -05:00
Ayaz Hafiz
593d609c2b
Check for unifiability of lambda sets without a subs snapshot
Gives nice performance wins, in particular avoiding clones of
unification tables, which can grow quite large.

Closes #3940
2022-08-31 08:56:45 -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