commit 0fe71fefceffb8ad40b1d312e5bf174701422461
parent 2c4facb682e16a8ac0d8315988d8621a2f6a48d8
Author: Demonstrandum <moi@knutsen.co>
Date: Sat, 13 Jun 2020 16:13:50 +0100
Display notes in error messages, if the exist.
Diffstat:
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/issue.rs b/src/issue.rs
@@ -180,6 +180,10 @@ impl fmt::Display for Issue {
}
}
+ let note_ascii = self.note_message.as_ref().map(|some|
+ format!("{} {}",
+ "|\n+-".yellow(), some.bold()));
+
if let Some(column) = self.site.location.column {
if opened_file {
if multi_line {
@@ -192,8 +196,20 @@ impl fmt::Display for Issue {
"^".repeat(columns).yellow().bold(),
space=" ".repeat(indent),
offset=(column + columns))?;
+ if let Some(note_fmt) = note_ascii {
+ let indented = note_fmt
+ .split("\n")
+ .map(|l| format!("{space} {line}",
+ line=l,
+ space=" ".repeat(indent + column)))
+ .collect::<Vec<String>>()
+ .join("\n");
+ writeln!(f, "{}", indented)?;
+ }
}
}
+ } else if let Some(note_fmt) = note_ascii {
+ writeln!(f, "{}", note_fmt)?;
}
Ok(())
diff --git a/src/syntax/analysis/type_resolver.rs b/src/syntax/analysis/type_resolver.rs
@@ -427,6 +427,7 @@ fn resolve_annotation(&mut self, appl_0 : ast::CallNode, appl_1 : ast::CallNode)
op_1.site().with_filename(&self.filename),
"Left of `:` type annotator must be \
an identifier; found `{}'.", op_1.node_type())
+ .note("Has to be a variable.")
.print();
}
} else {