fix assertione error on block parsing

This commit is contained in:
Aleksey Kladov 2018-08-25 13:21:43 +03:00
parent fed5727ea2
commit 838820ad98
4 changed files with 9 additions and 10 deletions

View File

@ -148,11 +148,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
p.eat(MOVE_KW);
params::param_list_opt_types(p);
if opt_fn_ret_type(p) {
if p.at(L_CURLY) {
block(p);
} else {
p.error("expected a block");
}
block(p);
} else {
expr(p);
}

View File

@ -26,7 +26,10 @@ fn expr_no_struct(p: &mut Parser) {
// fn c() { 1; 2; }
// fn d() { 1; 2 }
pub(crate) fn block(p: &mut Parser) {
assert!(p.at(L_CURLY));
if !p.at(L_CURLY) {
p.error("expected a block");
return;
}
let m = p.start();
p.bump();
while !p.at(EOF) && !p.at(R_CURLY) {

View File

@ -252,10 +252,10 @@ fn function(p: &mut Parser, flavor: ItemFlavor) {
// test fn_decl
// trait T { fn foo(); }
if p.at(L_CURLY) {
expressions::block(p);
if p.at(SEMI) {
p.bump();
} else {
p.expect(SEMI);
expressions::block(p)
}
}

View File

@ -8,7 +8,7 @@ ROOT@[0; 14)
L_PAREN@[6; 7)
err: `expected value parameter`
err: `expected R_PAREN`
err: `expected SEMI`
err: `expected a block`
err: `expected an item`
ERROR@[7; 8)
R_CURLY@[7; 8)