doughlang: let else, fn rety

ast:
- `let Pat (= Expr (else Expr)?)?`,
- `fn (args) -> Ty`, coagulating `do`, `if/while` formatting fixes

parser:
- int cleanup,
- fn rety parsing,
- experimental `for` desugar,
- experimental semicolon elision (TODO: it sucks),
- let-else parsing
- `do` coagulation impl (still not 100% there)

TODO:
- Fix `do` coagulation
- codify `do` elision rules
- `for` needs lib support
  - this is fine because we have no codegen yet
- Ty matching in macro_matcher
  - Or rip out macro_matcher? Who knows what the future holds.
This commit is contained in:
2025-10-16 01:51:14 -04:00
parent 95abb81f4a
commit 03d9682409
3 changed files with 227 additions and 52 deletions

View File

@@ -93,14 +93,17 @@ impl<A: Annotation> Match<A> for Const<A> {
impl<A: Annotation> Match<A> for Fn<A> {
fn recurse(sub: &mut Subst<A>, pat: &Self, expr: &Self) -> bool {
let (Self(pat_id, pat_arg, pat_body), Self(expr_id, expr_arg, expr_body)) = (pat, expr);
let (
Self(pat_id, pat_arg, _pat_rety, pat_body),
Self(expr_id, expr_arg, _expr_rety, expr_body),
) = (pat, expr);
pat_id == expr_id
&& Match::recurse(sub, pat_arg, expr_arg)
&& Match::recurse(sub, pat_body, expr_body)
}
fn apply(&mut self, sub: &Subst<A>) {
let Self(_, pat, body) = self;
let Self(_, pat, _rety, body) = self;
pat.apply(sub);
body.apply(sub);
}