Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma27 committed Nov 13, 2021
1 parent 850e358 commit 56131e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/error-report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn main() {
ParseError::UnexpectedExtra(range) => range,
ParseError::UnexpectedWanted(_, range, _) => range,
ParseError::UnexpectedDoubleBind(range) => range,
ParseError::DuplicatedArgs(range, _) => range,
err => {
eprintln!("error: {}", err);
continue;
Expand Down
10 changes: 5 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub enum ParseError {
UnexpectedEOF,
/// UnexpectedEOFWanted is used when specific tokens are expected, but the end of file is reached
UnexpectedEOFWanted(Box<[SyntaxKind]>),
/// UnexpectedDuplicatedArgs is used when formal arguments are duplicated, e.g. `{ a, a }`
UnexpectedDuplicatedArgs(TextRange, String),
/// DuplicatedArgs is used when formal arguments are duplicated, e.g. `{ a, a }`
DuplicatedArgs(TextRange, String),
}

impl fmt::Display for ParseError {
Expand Down Expand Up @@ -77,10 +77,10 @@ impl fmt::Display for ParseError {
ParseError::UnexpectedEOFWanted(kinds) => {
write!(f, "unexpected end of file, wanted any of {:?}", kinds)
}
ParseError::UnexpectedDuplicatedArgs(range, ident) => {
ParseError::DuplicatedArgs(range, ident) => {
write!(
f,
"argument `{}' is duplicated in {}..{}",
"argument `{}` is duplicated in {}..{}",
ident,
usize::from(range.start()),
usize::from(range.end())
Expand Down Expand Up @@ -363,7 +363,7 @@ where
self.start_error_node();
self.expect_ident();
let fin = self.finish_error_node();
self.errors.push(ParseError::UnexpectedDuplicatedArgs(
self.errors.push(ParseError::DuplicatedArgs(
TextRange::new(tp, fin),
id_str
));
Expand Down
2 changes: 1 addition & 1 deletion test_data/parser/patterns/8.expect
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: argument `a' is duplicated in 8..9
error: argument `a` is duplicated in 8..9
error: error node at 8..9
NODE_ROOT 0..14 {
NODE_LAMBDA 0..14 {
Expand Down

0 comments on commit 56131e0

Please # to comment.