@@ -39,92 +39,25 @@ let to_string t =
3939 ->
4040 " Here a OCaml polymorphic variant type passed into JS, probably you forgot annotations like `[@bs.int]` or `[@bs.string]` "
4141
42- let warning_formatter = Format. err_formatter
43-
44- let print_string_warning (loc : Location.t ) x =
45- if loc.loc_ghost then
46- Format. fprintf warning_formatter " File %s@." ! Location. input_name
47- else
48- Location. print warning_formatter loc ;
49- Format. fprintf warning_formatter " @{<error>Warning@}: %s@." x
5042
5143let prerr_bs_ffi_warning loc x =
52- Location. prerr_warning loc (Warnings. Bs_ffi_warning (to_string x))
53-
54- let unimplemented_primitive = " Unimplemented primitive used:"
55- type error =
56- | Uninterpreted_delimiters of string
57- | Unimplemented_primitive of string
58- exception Error of Location .t * error
59-
60- let pp_error fmt x =
61- match x with
62- | Unimplemented_primitive str ->
63- Format. pp_print_string fmt unimplemented_primitive;
64- Format. pp_print_string fmt str
65-
66- | Uninterpreted_delimiters str ->
67- Format. pp_print_string fmt " Uninterpreted delimiters" ;
68- Format. pp_print_string fmt str
69-
70-
44+ Location. prerr_warning loc (Bs_ffi_warning (to_string x))
7145
72- let () =
73- Location. register_error_of_exn (function
74- | Error (loc ,err ) ->
75- Some (Location. error_of_printer loc pp_error err)
76- | _ -> None
77- )
7846
7947
8048
8149
82- let warn_missing_primitive loc txt =
83- if not ! Js_config. no_warn_unimplemented_external && not ! Clflags. bs_quiet then
84- begin
85- print_string_warning loc ( unimplemented_primitive ^ txt ^ " \n " );
86- Format. pp_print_flush warning_formatter ()
87- end
50+ let warn_missing_primitive loc txt =
51+ Location. prerr_warning loc (Bs_unimplemented_primitive txt)
8852
8953let warn_literal_overflow loc =
90- if not ! Clflags. bs_quiet then
91- begin
92- print_string_warning loc
93- " Integer literal exceeds the range of representable integers of type int" ;
94- Format. pp_print_flush warning_formatter ()
95- end
54+ Location. prerr_warning loc Bs_integer_literal_overflow
9655
9756
9857
9958let error_unescaped_delimiter loc txt =
100- raise (Error (loc, Uninterpreted_delimiters txt))
101-
102-
103-
104-
105-
106-
107- (* *
108- Note the standard way of reporting error in compiler:
109-
110- val Location.register_error_of_exn : (exn -> Location.error option) -> unit
111- val Location.error_of_printer : Location.t ->
112- (Format.formatter -> error -> unit) -> error -> Location.error
113-
114- Define an error type
115-
116- type error
117- exception Error of Location.t * error
59+ Location. prerr_warning loc (Bs_uninterpreted_delimiters txt)
60+
11861
119- Provide a printer to error
12062
121- {[
122- let () =
123- Location.register_error_of_exn
124- (function
125- | Error(loc,err) ->
126- Some (Location.error_of_printer loc pp_error err)
127- | _ -> None
128- )
129- ]}
130- *)
63+
0 commit comments