summaryrefslogtreecommitdiff
path: root/src/syntax/parser.rs
diff options
context:
space:
mode:
authorLeedehai <18319900+Leedehai@users.noreply.github.com>2023-04-19 07:26:55 -0400
committerGitHub <noreply@github.com>2023-04-19 13:26:55 +0200
commitdc3017955a67e5509f6bc33cb9b4833806da4c22 (patch)
tree364304f23268107cb0443fc0037a86bd4136d9ef /src/syntax/parser.rs
parente4b09d417e9bfc2c0011299272f33c6861e96a6f (diff)
Give more specific error messages (#881)
Diffstat (limited to 'src/syntax/parser.rs')
-rw-r--r--src/syntax/parser.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/syntax/parser.rs b/src/syntax/parser.rs
index e6807404..4bc25a30 100644
--- a/src/syntax/parser.rs
+++ b/src/syntax/parser.rs
@@ -1046,8 +1046,8 @@ fn validate_dict(p: &mut Parser, m: Marker) {
None => first.text().clone(),
};
- if !used.insert(key) {
- first.convert_to_error("duplicate key");
+ if !used.insert(key.clone()) {
+ first.convert_to_error(eco_format!("duplicate key: {}", key));
child.make_erroneous();
}
}
@@ -1073,13 +1073,19 @@ fn validate_params(p: &mut Parser, m: Marker) {
match child.kind() {
SyntaxKind::Ident => {
if !used.insert(child.text().clone()) {
- child.convert_to_error("duplicate parameter");
+ child.convert_to_error(eco_format!(
+ "duplicate parameter: {}",
+ child.text()
+ ));
}
}
SyntaxKind::Named => {
let Some(within) = child.children_mut().first_mut() else { return };
if !used.insert(within.text().clone()) {
- within.convert_to_error("duplicate parameter");
+ within.convert_to_error(eco_format!(
+ "duplicate parameter: {}",
+ within.text()
+ ));
child.make_erroneous();
}
}
@@ -1101,7 +1107,10 @@ fn validate_params(p: &mut Parser, m: Marker) {
continue;
}
if !used.insert(within.text().clone()) {
- within.convert_to_error("duplicate parameter");
+ within.convert_to_error(eco_format!(
+ "duplicate parameter: {}",
+ within.text()
+ ));
child.make_erroneous();
}
}
@@ -1122,7 +1131,10 @@ fn validate_args(p: &mut Parser, m: Marker) {
if child.kind() == SyntaxKind::Named {
let Some(within) = child.children_mut().first_mut() else { return };
if !used.insert(within.text().clone()) {
- within.convert_to_error("duplicate argument");
+ within.convert_to_error(eco_format!(
+ "duplicate argument: {}",
+ within.text()
+ ));
child.make_erroneous();
}
}