Implement return keyword

This commit is contained in:
Sam Mohr 2024-10-20 04:50:12 -07:00
parent 20a539a96d
commit b3e60f9d3a
No known key found for this signature in database
GPG key ID: EA41D161A3C1BC99
39 changed files with 594 additions and 80 deletions

View file

@ -214,6 +214,7 @@ impl CompletionVisitor<'_> {
DeclarationInfo::Value {
expr_var, pattern, ..
} => self.patterns(pattern, expr_var),
DeclarationInfo::Return { .. } => vec![],
DeclarationInfo::Function {
expr_var,
pattern,

View file

@ -641,6 +641,7 @@ impl IterTokens for ValueDef<'_> {
onetoken(Token::Import, import.name.item.region, arena)
}
ValueDef::Stmt(loc_expr) => loc_expr.iter_tokens(arena),
ValueDef::Return(loc_expr) => loc_expr.iter_tokens(arena),
}
}
}
@ -718,6 +719,11 @@ impl IterTokens for Loc<Expr<'_>> {
Expr::When(e, branches) => (e.iter_tokens(arena).into_iter())
.chain(branches.iter_tokens(arena))
.collect_in(arena),
Expr::Return(ret_expr, after_ret) => ret_expr
.iter_tokens(arena)
.into_iter()
.chain(after_ret.iter_tokens(arena))
.collect_in(arena),
Expr::SpaceBefore(e, _) | Expr::SpaceAfter(e, _) => {
Loc::at(region, *e).iter_tokens(arena)
}