summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNadrieril2024-06-18 11:31:45 +0200
committerNadrieril2024-06-18 12:11:23 +0200
commitaa5948d7f9fd9b2d0ce18657215dae6877ebd996 (patch)
tree56008c815bfc43c3c63ef31489a853241983d87d
parent43a9fb0fa5a1c03a7cce575a052f0d4201189d1d (diff)
Tiny dedup
-rw-r--r--compiler/Errors.ml5
-rw-r--r--compiler/ExtractTypes.ml11
-rw-r--r--tests/src/mutually-recursive-traits.lean.out2
3 files changed, 5 insertions, 13 deletions
diff --git a/compiler/Errors.ml b/compiler/Errors.ml
index 6e2de7e1..838e1e37 100644
--- a/compiler/Errors.ml
+++ b/compiler/Errors.ml
@@ -1,7 +1,6 @@
let log = Logging.errors_log
-let span_to_string (span : Meta.span) =
- let raw_span = span.span in
+let raw_span_to_string (raw_span : Meta.raw_span) =
let file = match raw_span.file with Virtual s | Local s -> s in
let loc_to_string (l : Meta.loc) : string =
string_of_int l.line ^ ":" ^ string_of_int l.col
@@ -11,6 +10,8 @@ let span_to_string (span : Meta.span) =
^ "-"
^ loc_to_string raw_span.end_loc
+let span_to_string (span : Meta.span) = raw_span_to_string span.span
+
let format_error_message (span : Meta.span option) (msg : string) =
let span =
match span with None -> "" | Some span -> "\n" ^ span_to_string span
diff --git a/compiler/ExtractTypes.ml b/compiler/ExtractTypes.ml
index 631db13e..edd9d58e 100644
--- a/compiler/ExtractTypes.ml
+++ b/compiler/ExtractTypes.ml
@@ -1162,16 +1162,7 @@ let extract_comment_with_raw_span (ctx : extraction_ctx) (fmt : F.formatter)
(sl : string list) (name : Types.name option)
?(generics : (Types.generic_params * Types.generic_args) option = None)
(raw_span : Meta.raw_span) : unit =
- let file = match raw_span.file with Virtual s | Local s -> s in
- let loc_to_string (l : Meta.loc) : string =
- string_of_int l.line ^ ":" ^ string_of_int l.col
- in
- let raw_span =
- "Source: '" ^ file ^ "', lines "
- ^ loc_to_string raw_span.beg_loc
- ^ "-"
- ^ loc_to_string raw_span.end_loc
- in
+ let raw_span = raw_span_to_string raw_span in
let name =
match (name, generics) with
| None, _ -> []
diff --git a/tests/src/mutually-recursive-traits.lean.out b/tests/src/mutually-recursive-traits.lean.out
index 9b3b0737..d4ca5af3 100644
--- a/tests/src/mutually-recursive-traits.lean.out
+++ b/tests/src/mutually-recursive-traits.lean.out
@@ -9,7 +9,7 @@ Uncaught exception:
\nIn file Translate.ml, line 813:\
\nMutually recursive trait declarations are not supported")
-Raised at Aeneas__Errors.craise_opt_span in file "Errors.ml", line 46, characters 4-76
+Raised at Aeneas__Errors.craise_opt_span in file "Errors.ml", line 47, characters 4-76
Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
Called from Aeneas__Translate.extract_definitions in file "Translate.ml", line 836, characters 2-52
Called from Aeneas__Translate.extract_file in file "Translate.ml", line 963, characters 2-36