
louise
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#1197 · main · 10 min 35 s
1Étoiles
0Forks
0Issues
Types: generic associated types with quantified bindings (issue #234)
ADR 0047, fourth part. Associated types with their own parameters
already reduced since the first part (`Mapped<c, x>`, the trait's
arguments then its own). This adds their bindings, which quantify those
parameters: `where Mappable<c, Mapped<y> = List<y>>` says that mapping
`c` gives a list whatever `y` is.
- **`Equality`** (`lhs`, `rhs`, `binders`) replaces the `(Ty, Ty)` pairs
of schemes, arms, givens and leftovers. Binders are the variables a
binding quantifies, as they stand in it.
- **Lowering:**
- a binding's parameters are in scope for that binding only: scheme
variables in a signature, rigids in its body, inference variables
elsewhere;
- a parameter may not reuse a name of the signature (E0416), so a
printed signature reads back the same.
- **At a call:** each binder is a fresh *scoped* rigid, named as the
binding names it, so the call must satisfy the binding for every type.
The escape check keeps such a rigid from being captured outside.
- **In a body,** or in a matched constructor's arm, a quantified given
matches a projection's own arguments one way, like a rewrite rule.
- **Determinedness:** binders need no determining.
- **Printing:** `Mappable<c, Mapped<y> = List<y>>`.
Own parameters are types, and a projection is always fully applied, so
`Functor<Mapped<c>>` is a kind error.
Tests:
- `tests/run/gats.lse` on both backends: two impls, and bodies relying on
quantified bindings.
- `tests/ui/assoc_types.lse`: the printed scheme; a call whose impl breaks
the binding (`expected Mapped<Duo, y>, found List<y>`); a binder named
like a signature variable.
The generated C of every existing program is byte-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>Parents a7a312e
10 fichiers modifiés, 239 ajouts, 47 suppressions
crates/louise_types/src/env/mod.rs+46−14crates/louise_types/src/infer/mod.rs+31−4crates/louise_types/src/infer/pat.rs+2−2crates/louise_types/src/lib.rs+9−11crates/louise_types/src/traits.rs+1−1crates/louise_types/src/ty.rs+72−13docs/reference/diagnostics.md+1−1docs/reference/language.md+1−1tests/run/gats.lse+44−0tests/ui/assoc_types.lse+32−0