summaryrefslogtreecommitdiff
path: root/compiler/Main.ml
diff options
context:
space:
mode:
authorSon Ho2024-03-29 11:31:47 +0100
committerSon Ho2024-03-29 11:31:47 +0100
commit6f4833f84dd3ec17311b5e6ca9f5c1ad94ff7564 (patch)
tree630b4ec048005180e2651a56ef9b890fc6c33069 /compiler/Main.ml
parentc2069900aa534d49b6c07eea8f5ab2fb70a26aa2 (diff)
Improve the error messages
Diffstat (limited to '')
-rw-r--r--compiler/Main.ml31
1 files changed, 23 insertions, 8 deletions
diff --git a/compiler/Main.ml b/compiler/Main.ml
index 41addc81..88c32ca9 100644
--- a/compiler/Main.ml
+++ b/compiler/Main.ml
@@ -267,16 +267,31 @@ let () =
definitions";
fail ());
- (* Apply the pre-passes *)
- let m = Aeneas.PrePasses.apply_passes m in
+ (try
+ (* Apply the pre-passes *)
+ let m = Aeneas.PrePasses.apply_passes m in
- (* Some options for the execution *)
+ (* Test the unit functions with the concrete interpreter *)
+ if !test_unit_functions then Test.test_unit_functions m;
- (* Test the unit functions with the concrete interpreter *)
- if !test_unit_functions then Test.test_unit_functions m;
-
- (* Translate the functions *)
- Aeneas.Translate.translate_crate filename dest_dir m;
+ (* Translate the functions *)
+ Aeneas.Translate.translate_crate filename dest_dir m
+ with Errors.CFailure msg ->
+ (* In theory it shouldn't happen, but there may be uncaught errors -
+ note that we let the Failure errors go through *)
+ (* The error should have been saved *)
+ let meta =
+ match !Errors.error_list with
+ | (m, _) :: _ -> m
+ | _ -> (* Want to be safe here *) None
+ in
+ let msg =
+ match meta with
+ | None -> msg
+ | Some m -> Errors.format_error_message m msg
+ in
+ log#serror msg;
+ exit 1);
(* Print total elapsed time *)
log#linfo