Skip to content

Commit 18cac49

Browse files
committed
Improve error message when parsing Ident encounters keyword
1 parent 25def51 commit 18cac49

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/ident.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ mod parsing {
7676
input.step(|cursor| {
7777
if let Some((ident, rest)) = cursor.ident() {
7878
if accept_as_ident(&ident) {
79-
return Ok((ident, rest));
79+
Ok((ident, rest))
80+
} else {
81+
Err(cursor.error(format_args!(
82+
"expected identifier, found keyword `{}`",
83+
ident,
84+
)))
8085
}
86+
} else {
87+
Err(cursor.error("expected identifier"))
8188
}
82-
Err(cursor.error("expected identifier"))
8389
})
8490
}
8591
}

0 commit comments

Comments
 (0)