[fine] Even more resilience, I can stop now

Also fix a bug, could not return from a method OOPS
This commit is contained in:
John Doty 2024-02-01 06:35:43 -08:00
parent 7f30d0ccc3
commit f7acfd588d
3 changed files with 9 additions and 2 deletions

View file

@ -675,6 +675,13 @@ fn return_type(p: &mut CParser) {
p.expect_start(TokenKind::Arrow);
type_expr(p);
if !p.at(TokenKind::LeftBrace) {
p.error("expected a block after a return type");
while !p.at_any(STATEMENT_RECOVERY) && !p.eof() {
p.advance();
}
}
p.end(m, TreeKind::ReturnType);
}

View file

@ -1907,7 +1907,7 @@ fn check_return_statement(s: &Semantics, tree: &Tree) {
let function_type = s.type_of(enclosing_function);
match function_type {
Type::Function(_, expected_type) => {
Type::Function(_, expected_type) | Type::Method(_, _, expected_type) => {
let actual_type = if let Some(expr) = tree.nth_tree(1) {
s.type_of(expr)
} else {

View file

@ -127,5 +127,5 @@ fun test() -> f64 {
// like the above.
}
/// @ignore WIP
// @ignore WIP
// @no-errors