diff options
author | Escherichia | 2024-04-04 13:23:50 +0200 |
---|---|---|
committer | Escherichia | 2024-04-04 13:23:50 +0200 |
commit | 16ea3ca854a77703487afa8732f247bc26cba695 (patch) | |
tree | 7572c16393da5d2b2ddbbcfdde68b30470fe1ed9 | |
parent | b041b2eb7f1d03b815b4726b3aa0a7aa98124b4d (diff) |
Now prints all errors in the error_list
-rw-r--r-- | compiler/Errors.ml | 6 | ||||
-rw-r--r-- | compiler/Main.ml | 8 |
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/Errors.ml b/compiler/Errors.ml index 30887593..7dfe659a 100644 --- a/compiler/Errors.ml +++ b/compiler/Errors.ml @@ -20,6 +20,12 @@ let format_error_message_with_file_line (file : string) (line : int) "In file " ^ file ^ ", line " ^ string_of_int line ^ ":\n" ^ format_error_message meta msg +let error_list_to_string (error_list : (Meta.meta option * string) list) : + string = + List.fold_left + (fun errors (meta, msg) -> errors ^ "\n" ^ format_error_message meta msg) + "" error_list + exception CFailure of (Meta.meta option * string) let error_list : (Meta.meta option * string) list ref = ref [] diff --git a/compiler/Main.ml b/compiler/Main.ml index db200f37..9e72a21b 100644 --- a/compiler/Main.ml +++ b/compiler/Main.ml @@ -274,12 +274,14 @@ let () = (* Translate the functions *) Aeneas.Translate.translate_crate filename dest_dir m - with Errors.CFailure (meta, msg) -> + with Errors.CFailure (_, _) -> (* In theory it shouldn't happen, but there may be uncaught errors - note that we let the [Failure] exceptions go through (they are send if we use the option [-abort-on-error] *) - log#serror (Errors.format_error_message meta msg); - exit 1); + if not (List.is_empty !Errors.error_list) then ( + let errors = Errors.error_list_to_string !Errors.error_list in + log#serror errors; + exit 1)); (* Print total elapsed time *) log#linfo |