Improved semantic errors

This commit is contained in:
2026-06-16 15:37:34 +02:00
parent bbb94a4f97
commit ecfff0ac0d
2 changed files with 24 additions and 12 deletions
+11 -9
View File
@@ -186,7 +186,7 @@ fn is_source_newer(source *Path, output *Path) std::io::Result<bool> {
pub enum TranspileError<'a> {
Parse[error::ParseError<'a, Vec<mist_parser::ast::TopLevel>>],
Semantic[mist_parser::semantics::SemanticError]
Semantic[Vec<mist_parser::semantics::SemanticError>]
}
pub fn transpile_code<'a>(path *PathBuf, source *'a str, mut output_file PathBuf, mod_decl *str, curr_mod_decl *Option<[mist_parser::ast::Visibility, mist_parser::ast::Identifier]>)
@@ -262,14 +262,16 @@ pub fn decode_err<'a>(err *TranspileError<'a>, path *PathBuf) {
let curr_dir = std::env::current_dir().unwrap();
match err {
TranspileError::Semantic[e] => {
eprintln!(
"\n{}:{}:{}\n \x1b[31mError\x1b[0m: {}",
path.strip_prefix(curr_dir).unwrap_or_else(|_| path).as_os_str().display(),
e.line,
e.column,
e.error_message,
);
TranspileError::Semantic[e_list] => {
for e in e_list {
eprintln!(
"\n{}:{}:{}\n \x1b[31mError\x1b[0m: {}",
path.strip_prefix(&curr_dir).unwrap_or_else(|_| path).as_os_str().display(),
e.line,
e.column,
e.error_message,
);
}
}
TranspileError::Parse[e] => {