Skip to content

Commit fafcf3c

Browse files
committed
Remove more stuff
1 parent 29f24e1 commit fafcf3c

File tree

6 files changed

+5
-103
lines changed

6 files changed

+5
-103
lines changed

compiler/jsoo/jsoo_playground_main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ module ResDriver = struct
242242
{loc_start = start_pos; Location.loc_end = end_pos; loc_ghost = false}
243243
in
244244
let err = {Location.loc; msg; sub = []; if_highlight = ""} in
245-
Location.default_error_reporter ~src:(Some src) Format.str_formatter err;
245+
Location.report_error ~src:(Some src) Format.str_formatter err;
246246
Format.flush_str_formatter ()
247247

248248
let parse_implementation ~sourcefile ~for_printer ~src =

compiler/ml/env.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,10 +1035,6 @@ let rec lookup_module_descr_aux ?loc lid env =
10351035
and lookup_module_descr ?loc lid env =
10361036
let ((p, comps) as res) = lookup_module_descr_aux ?loc lid env in
10371037
mark_module_used env (Path.last p) comps.loc;
1038-
(*
1039-
Format.printf "USE module %s at %a@." (Path.last p)
1040-
Location.print comps.loc;
1041-
*)
10421038
report_deprecated ?loc p comps.deprecated;
10431039
res
10441040

compiler/ml/location.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ let error_of_exn exn =
231231

232232
(* taken from https://github.com/rescript-lang/ocaml/blob/d4144647d1bf9bc7dc3aadc24c25a7efa3a67915/parsing/location.ml#L380 *)
233233
(* This is the error report entry point. We'll replace the default reporter with this one. *)
234-
let rec default_error_reporter ?(src = None) ppf {loc; msg; sub} =
234+
let rec report_error ?(src = None) ppf {loc; msg; sub} =
235235
setup_colors ();
236236
(* open a vertical box. Everything in our message is indented 2 spaces *)
237237
(* If src is given, it will display a syntax error after parsing. *)
@@ -243,13 +243,9 @@ let rec default_error_reporter ?(src = None) ppf {loc; msg; sub} =
243243
Format.fprintf ppf "@[<v>@, %a@, %s@,@]"
244244
(print ~src ~message_kind:`error intro)
245245
loc msg;
246-
List.iter (Format.fprintf ppf "@,@[%a@]" (default_error_reporter ~src)) sub
246+
List.iter (Format.fprintf ppf "@,@[%a@]" (report_error ~src)) sub
247247
(* no need to flush here; location's report_exception (which uses this ultimately) flushes *)
248248

249-
let error_reporter = ref default_error_reporter
250-
251-
let report_error ?(src = None) ppf err = !error_reporter ~src ppf err
252-
253249
let error_of_printer loc print x = errorf ~loc "%a@?" print x
254250

255251
let error_of_printer_file print x =

compiler/ml/location.mli

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ type 'a loc = {txt: 'a; loc: t}
5757
val mknoloc : 'a -> 'a loc
5858
val mkloc : 'a -> t -> 'a loc
5959

60-
val print :
61-
?src:string option ->
62-
message_kind:[< `error | `warning | `warning_as_error > `warning] ->
63-
string ->
64-
formatter ->
65-
t ->
66-
unit
6760
val print_filename : formatter -> string -> unit
6861

6962
val show_filename : string -> string
@@ -112,12 +105,6 @@ val register_error_of_exn : (exn -> error option) -> unit
112105

113106
val report_error : ?src:string option -> formatter -> error -> unit
114107

115-
val error_reporter : (?src:string option -> formatter -> error -> unit) ref
116-
(** Hook for intercepting error reports. *)
117-
118-
val default_error_reporter : ?src:string option -> formatter -> error -> unit
119-
(** Original error reporter for use in hooks. *)
120-
121108
val report_exception : formatter -> exn -> unit
122109
(** Reraise the exception if it is unknown. *)
123110

compiler/ml/syntaxerr.ml

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,66 +15,6 @@
1515

1616
(* Auxiliary type for reporting syntax errors *)
1717

18-
type error =
19-
| Unclosed of Location.t * string * Location.t * string
20-
| Expecting of Location.t * string
21-
| Not_expecting of Location.t * string
22-
| Applicative_path of Location.t
23-
| Variable_in_scope of Location.t * string
24-
| Other of Location.t
25-
| Ill_formed_ast of Location.t * string
26-
| Invalid_package_type of Location.t * string
18+
type error = Variable_in_scope of Location.t * string
2719

2820
exception Error of error
29-
exception Escape_error
30-
31-
let prepare_error = function
32-
| Unclosed (opening_loc, opening, closing_loc, closing) ->
33-
Location.errorf ~loc:closing_loc
34-
~sub:
35-
[
36-
Location.errorf ~loc:opening_loc "This '%s' might be unmatched" opening;
37-
]
38-
~if_highlight:
39-
(Printf.sprintf
40-
"Syntax error: '%s' expected, the highlighted '%s' might be \
41-
unmatched"
42-
closing opening)
43-
"Syntax error: '%s' expected" closing
44-
| Expecting (loc, nonterm) ->
45-
Location.errorf ~loc "Syntax error: %s expected." nonterm
46-
| Not_expecting (loc, nonterm) ->
47-
Location.errorf ~loc "Syntax error: %s not expected." nonterm
48-
| Applicative_path loc ->
49-
Location.errorf ~loc
50-
"Syntax error: applicative paths of the form F(X).t are not supported \
51-
when the option -no-app-func is set."
52-
| Variable_in_scope (loc, var) ->
53-
Location.errorf ~loc
54-
"In this scoped type, variable '%s is reserved for the local type %s." var
55-
var
56-
| Other loc -> Location.errorf ~loc "Syntax error"
57-
| Ill_formed_ast (loc, s) ->
58-
Location.errorf ~loc "broken invariant in parsetree: %s" s
59-
| Invalid_package_type (loc, s) ->
60-
Location.errorf ~loc "invalid package type: %s" s
61-
62-
let () =
63-
Location.register_error_of_exn (function
64-
| Error err -> Some (prepare_error err)
65-
| _ -> None)
66-
67-
let report_error ppf err = Location.report_error ppf (prepare_error err)
68-
69-
let location_of_error = function
70-
| Unclosed (l, _, _, _)
71-
| Applicative_path l
72-
| Variable_in_scope (l, _)
73-
| Other l
74-
| Not_expecting (l, _)
75-
| Ill_formed_ast (l, _)
76-
| Invalid_package_type (l, _)
77-
| Expecting (l, _) ->
78-
l
79-
80-
let ill_formed_ast loc s = raise (Error (Ill_formed_ast (loc, s)))

compiler/ml/syntaxerr.mli

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,6 @@
1515

1616
(** Auxiliary type for reporting syntax errors *)
1717

18-
open Format
19-
20-
type error =
21-
| Unclosed of Location.t * string * Location.t * string
22-
| Expecting of Location.t * string
23-
| Not_expecting of Location.t * string
24-
| Applicative_path of Location.t
25-
| Variable_in_scope of Location.t * string
26-
| Other of Location.t
27-
| Ill_formed_ast of Location.t * string
28-
| Invalid_package_type of Location.t * string
18+
type error = Variable_in_scope of Location.t * string
2919

3020
exception Error of error
31-
exception Escape_error
32-
33-
val report_error : formatter -> error -> unit
34-
(** @deprecated Use {!Location.error_of_exn}, {!Location.report_error}. *)
35-
36-
val location_of_error : error -> Location.t
37-
val ill_formed_ast : Location.t -> string -> 'a

0 commit comments

Comments
 (0)