integrate ast::Location into compilre-core::Location

This commit is contained in:
Jeong YunWon 2022-08-22 08:38:21 +09:00
parent a22abc5550
commit 9d6ab72d79
12 changed files with 34 additions and 99 deletions

View file

@ -30,13 +30,10 @@ impl fmt::Display for CompileError {
let loc = self.location;
if let Some(ref stmt) = self.statement {
// visualize the error when location and statement are provided
write!(
f,
"{}",
loc.visualize(stmt, &format_args!("{} at {}", self.error, loc))
)
loc.fmt_with(f, &self.error)?;
write!(f, "\n{stmt}{arrow:>pad$}", pad = loc.column(), arrow = "^")
} else {
write!(f, "{} at {}", self.error, loc)
loc.fmt_with(f, &self.error)
}
}
}