improve error reporting for missing else
clauses
This commit is contained in:
parent
ec773b7fe1
commit
958cab5452
|
@ -497,6 +497,7 @@ fn lambda(p: &mut Parser) -> Closed {
|
||||||
fn if_expr(p: &mut Parser) -> Closed {
|
fn if_expr(p: &mut Parser) -> Closed {
|
||||||
let o = p.open();
|
let o = p.open();
|
||||||
|
|
||||||
|
let if_span = p.span();
|
||||||
p.advance(); // if
|
p.advance(); // if
|
||||||
if p.peek() != TokenKind::LParen {
|
if p.peek() != TokenKind::LParen {
|
||||||
let span = p.span();
|
let span = p.span();
|
||||||
|
@ -522,9 +523,8 @@ fn if_expr(p: &mut Parser) -> Closed {
|
||||||
p.optional_newline();
|
p.optional_newline();
|
||||||
|
|
||||||
if p.peek() != TokenKind::Else {
|
if p.peek() != TokenKind::Else {
|
||||||
let span = p.span();
|
|
||||||
p.emit(Diagnostic::error(
|
p.emit(Diagnostic::error(
|
||||||
span,
|
if_span,
|
||||||
"`if` expression is missing an `else` clause",
|
"`if` expression is missing an `else` clause",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue