Recover better on missing parameter in param list

This commit is contained in:
Lukas Wirth 2023-09-29 12:48:46 +02:00
parent f19479a2ad
commit a382e649ca
3 changed files with 50 additions and 1 deletions

View file

@ -7,6 +7,9 @@ use super::*;
// fn b(x: i32) {}
// fn c(x: i32, ) {}
// fn d(x: i32, y: ()) {}
// test_err empty_param_slot
// fn f(y: i32, ,t: i32) {}
pub(super) fn param_list_fn_def(p: &mut Parser<'_>) {
list_(p, Flavor::FnDef);
}
@ -71,7 +74,11 @@ fn list_(p: &mut Parser<'_>, flavor: Flavor) {
if !p.at_ts(PARAM_FIRST.union(ATTRIBUTE_FIRST)) {
p.error("expected value parameter");
m.abandon(p);
break;
if p.eat(T![,]) {
continue;
} else {
break;
}
}
param(p, m, flavor);
if !p.at(T![,]) {