From 56131e0c3a5b30531387a86b48836095df19f0ed Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 13 Nov 2021 16:30:31 +0100 Subject: [PATCH] Review fixes --- examples/error-report.rs | 1 + src/parser.rs | 10 +++++----- test_data/parser/patterns/8.expect | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/examples/error-report.rs b/examples/error-report.rs index ebf21c2..3d48de5 100644 --- a/examples/error-report.rs +++ b/examples/error-report.rs @@ -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; diff --git a/src/parser.rs b/src/parser.rs index 2a1b8ea..a5103c6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -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 { @@ -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()) @@ -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 )); diff --git a/test_data/parser/patterns/8.expect b/test_data/parser/patterns/8.expect index bf9b88f..75e6eec 100644 --- a/test_data/parser/patterns/8.expect +++ b/test_data/parser/patterns/8.expect @@ -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 {