Skip to content

Commit 8557a86

Browse files
committed
Also enable more warnings in stdlib/ and fix them.
1 parent 502e4f9 commit 8557a86

31 files changed

+166
-98
lines changed

stdlib/Makefile.shared

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ TARGET_BINDIR ?= $(BINDIR)
2020

2121
COMPILER=../ocamlc
2222
CAMLC=$(CAMLRUN) $(COMPILER)
23-
COMPFLAGS=-strict-sequence -w +32+33..39 -g -warn-error A -bin-annot -nostdlib \
24-
-safe-string
23+
COMPFLAGS=-strict-sequence -absname -w +a-4-9-41-42-44-45-48 -g -warn-error A -bin-annot -nostdlib \
24+
-safe-string -strict-formats
2525
ifeq "$(FLAMBDA)" "true"
2626
OPTCOMPFLAGS=-O3
2727
else

stdlib/arg.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ open Printf
5353
let rec assoc3 x l =
5454
match l with
5555
| [] -> raise Not_found
56-
| (y1, y2, y3) :: t when y1 = x -> y2
56+
| (y1, y2, _) :: _ when y1 = x -> y2
5757
| _ :: t -> assoc3 x t
5858
;;
5959

@@ -293,7 +293,7 @@ let add_padding len ksd =
293293
(* Do not pad undocumented options, so that they still don't show up when
294294
* run through [usage] or [parse]. *)
295295
ksd
296-
| (kwd, (Symbol (l, _) as spec), msg) ->
296+
| (kwd, (Symbol _ as spec), msg) ->
297297
let cutcol = second_word msg in
298298
let spaces = String.make ((max 0 (len - cutcol)) + 3) ' ' in
299299
(kwd, spec, "\n" ^ spaces ^ msg)

stdlib/arg.mli

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ val usage_string : (key * spec * doc) list -> usage_msg -> string
143143
(** Returns the message that would have been printed by {!Arg.usage},
144144
if provided with the same parameters. *)
145145

146-
val align: ?limit: int -> (key * spec * doc) list -> (key * spec * doc) list;;
146+
val align: ?limit: int -> (key * spec * doc) list -> (key * spec * doc) list
147147
(** Align the documentation strings by inserting spaces at the first
148148
space, according to the length of the keyword. Use a
149149
space as the first character in a doc string if you want to

stdlib/array.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ let to_list a =
131131
(* Cannot use List.length here because the List module depends on Array. *)
132132
let rec list_length accu = function
133133
| [] -> accu
134-
| h::t -> list_length (succ accu) t
134+
| _::t -> list_length (succ accu) t
135135
;;
136136

137137
let of_list = function

stdlib/camlinternalFormatBasics.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ let rec erase_rel : type a b c d e f g h i j k l .
540540
Bool_ty (erase_rel rest)
541541
| Format_arg_ty (ty, rest) ->
542542
Format_arg_ty (ty, erase_rel rest)
543-
| Format_subst_ty (ty1, ty2, rest) ->
543+
| Format_subst_ty (ty1, _ty2, rest) ->
544544
Format_subst_ty (ty1, ty1, erase_rel rest)
545545
| Alpha_ty rest ->
546546
Alpha_ty (erase_rel rest)

stdlib/camlinternalMod.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ let rec update_mod shape o n =
7171
for i = 0 to Array.length comps - 1 do
7272
update_mod comps.(i) (Obj.field o i) (Obj.field n i)
7373
done
74-
| Value v -> () (* the value is already there *)
74+
| Value _ -> () (* the value is already there *)

stdlib/camlinternalOO.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -457,20 +457,20 @@ let lookup_tables root keys =
457457

458458
(**** builtin methods ****)
459459

460-
let get_const x = ret (fun obj -> x)
460+
let get_const x = ret (fun _obj -> x)
461461
let get_var n = ret (fun obj -> Array.unsafe_get obj n)
462462
let get_env e n =
463463
ret (fun obj ->
464464
Array.unsafe_get (Obj.magic (Array.unsafe_get obj e) : obj) n)
465465
let get_meth n = ret (fun obj -> sendself obj n)
466466
let set_var n = ret (fun obj x -> Array.unsafe_set obj n x)
467-
let app_const f x = ret (fun obj -> f x)
467+
let app_const f x = ret (fun _obj -> f x)
468468
let app_var f n = ret (fun obj -> f (Array.unsafe_get obj n))
469469
let app_env f e n =
470470
ret (fun obj ->
471471
f (Array.unsafe_get (Obj.magic (Array.unsafe_get obj e) : obj) n))
472472
let app_meth f n = ret (fun obj -> f (sendself obj n))
473-
let app_const_const f x y = ret (fun obj -> f x y)
473+
let app_const_const f x y = ret (fun _obj -> f x y)
474474
let app_const_var f x n = ret (fun obj -> f x (Array.unsafe_get obj n))
475475
let app_const_meth f x n = ret (fun obj -> f x (sendself obj n))
476476
let app_var_const f n x = ret (fun obj -> f (Array.unsafe_get obj n) x)

stdlib/ephemeron.ml

+10-10
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module GenHashTable = struct
5555

5656
and 'a bucketlist =
5757
| Empty
58-
| Cons of int (** hash of the key *) * 'a H.container * 'a bucketlist
58+
| Cons of int (* hash of the key *) * 'a H.container * 'a bucketlist
5959

6060
(** the hash of the key is kept in order to test the equality of the hash
6161
before the key. Same reason as for Weak.Make *)
@@ -167,7 +167,7 @@ module GenHashTable = struct
167167
| ETrue -> h.size <- h.size - 1; next
168168
| EFalse -> Cons(hk, c, remove_bucket next)
169169
| EDead ->
170-
(** The dead key is automatically removed. It is acceptable
170+
(* The dead key is automatically removed. It is acceptable
171171
for this function since it already removes a binding *)
172172
h.size <- h.size - 1;
173173
remove_bucket next
@@ -188,7 +188,7 @@ module GenHashTable = struct
188188
| ETrue ->
189189
begin match H.get_data c with
190190
| None ->
191-
(** This case is not impossible because the gc can run between
191+
(* This case is not impossible because the gc can run between
192192
H.equal and H.get_data *)
193193
find_rec key hkey rest
194194
| Some d -> d
@@ -202,7 +202,7 @@ module GenHashTable = struct
202202

203203
let find h key =
204204
let hkey = H.hash h.seed key in
205-
(** TODO inline 3 iterations *)
205+
(* TODO inline 3 iterations *)
206206
find_rec key hkey (h.data.(key_index h hkey))
207207

208208
let find_all h key =
@@ -256,7 +256,7 @@ module GenHashTable = struct
256256
| ETrue -> true
257257
| EFalse | EDead -> mem_in_bucket rest
258258
end
259-
| Cons(hk, c, rest) -> mem_in_bucket rest in
259+
| Cons(_hk, _c, rest) -> mem_in_bucket rest in
260260
mem_in_bucket h.data.(key_index h hkey)
261261

262262
let iter f h =
@@ -401,7 +401,7 @@ module K1 = struct
401401
c
402402
let hash = H.hash
403403
let equal c k =
404-
(** {!get_key_copy} is not used because the equality of the user can be
404+
(* {!get_key_copy} is not used because the equality of the user can be
405405
the physical equality *)
406406
match get_key c with
407407
| None -> GenHashTable.EDead
@@ -421,7 +421,7 @@ module K1 = struct
421421
include MakeSeeded(struct
422422
type t = H.t
423423
let equal = H.equal
424-
let hash (seed: int) x = H.hash x
424+
let hash (_seed: int) x = H.hash x
425425
end)
426426
let create sz = create ~random:false sz
427427
end
@@ -504,12 +504,12 @@ module K2 = struct
504504
(struct
505505
type t = H1.t
506506
let equal = H1.equal
507-
let hash (seed: int) x = H1.hash x
507+
let hash (_seed: int) x = H1.hash x
508508
end)
509509
(struct
510510
type t = H2.t
511511
let equal = H2.equal
512-
let hash (seed: int) x = H2.hash x
512+
let hash (_seed: int) x = H2.hash x
513513
end)
514514
let create sz = create ~random:false sz
515515
end
@@ -609,7 +609,7 @@ module Kn = struct
609609
include MakeSeeded(struct
610610
type t = H.t
611611
let equal = H.equal
612-
let hash (seed: int) x = H.hash x
612+
let hash (_seed: int) x = H.hash x
613613
end)
614614
let create sz = create ~random:false sz
615615
end

stdlib/ephemeron.mli

+36-4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ module type S = sig
8080

8181
val clean: 'a t -> unit
8282
(** remove all dead bindings. Done automatically during automatic resizing. *)
83+
8384
val stats_alive: 'a t -> Hashtbl.statistics
8485
(** same as {!Hashtbl.SeededS.stats} but only count the alive bindings *)
8586
end
@@ -93,6 +94,7 @@ module type SeededS = sig
9394
include Hashtbl.SeededS
9495
val clean: 'a t -> unit
9596
(** remove all dead bindings. Done automatically during automatic resizing. *)
97+
9698
val stats_alive: 'a t -> Hashtbl.statistics
9799
(** same as {!Hashtbl.SeededS.stats} but only count the alive bindings *)
98100
end
@@ -192,43 +194,58 @@ module K2 : sig
192194

193195
val get_key1: ('k1,'k2,'d) t -> 'k1 option
194196
(** Same as {!Ephemeron.K1.get_key} *)
197+
195198
val get_key1_copy: ('k1,'k2,'d) t -> 'k1 option
196199
(** Same as {!Ephemeron.K1.get_key_copy} *)
200+
197201
val set_key1: ('k1,'k2,'d) t -> 'k1 -> unit
198202
(** Same as {!Ephemeron.K1.set_key} *)
203+
199204
val unset_key1: ('k1,'k2,'d) t -> unit
200205
(** Same as {!Ephemeron.K1.unset_key} *)
206+
201207
val check_key1: ('k1,'k2,'d) t -> bool
202208
(** Same as {!Ephemeron.K1.check_key} *)
203209

204210
val get_key2: ('k1,'k2,'d) t -> 'k2 option
205211
(** Same as {!Ephemeron.K1.get_key} *)
212+
206213
val get_key2_copy: ('k1,'k2,'d) t -> 'k2 option
207214
(** Same as {!Ephemeron.K1.get_key_copy} *)
215+
208216
val set_key2: ('k1,'k2,'d) t -> 'k2 -> unit
209217
(** Same as {!Ephemeron.K1.get_key} *)
218+
210219
val unset_key2: ('k1,'k2,'d) t -> unit
211220
(** Same as {!Ephemeron.K1.unset_key} *)
221+
212222
val check_key2: ('k1,'k2,'d) t -> bool
213223
(** Same as {!Ephemeron.K1.check_key} *)
214224

215-
val blit_key1 : ('k1,_,_) t -> ('k1,_,_) t -> unit
225+
val blit_key1: ('k1,_,_) t -> ('k1,_,_) t -> unit
216226
(** Same as {!Ephemeron.K1.blit_key} *)
217-
val blit_key2 : (_,'k2,_) t -> (_,'k2,_) t -> unit
227+
228+
val blit_key2: (_,'k2,_) t -> (_,'k2,_) t -> unit
218229
(** Same as {!Ephemeron.K1.blit_key} *)
219-
val blit_key12 : ('k1,'k2,_) t -> ('k1,'k2,_) t -> unit
230+
231+
val blit_key12: ('k1,'k2,_) t -> ('k1,'k2,_) t -> unit
220232
(** Same as {!Ephemeron.K1.blit_key} *)
221233

222234
val get_data: ('k1,'k2,'d) t -> 'd option
223235
(** Same as {!Ephemeron.K1.get_data} *)
236+
224237
val get_data_copy: ('k1,'k2,'d) t -> 'd option
225238
(** Same as {!Ephemeron.K1.get_data_copy} *)
239+
226240
val set_data: ('k1,'k2,'d) t -> 'd -> unit
227241
(** Same as {!Ephemeron.K1.set_data} *)
242+
228243
val unset_data: ('k1,'k2,'d) t -> unit
229244
(** Same as {!Ephemeron.K1.unset_data} *)
245+
230246
val check_data: ('k1,'k2,'d) t -> bool
231247
(** Same as {!Ephemeron.K1.check_data} *)
248+
232249
val blit_data: ('k1,'k2,'d) t -> ('k1,'k2,'d) t -> unit
233250
(** Same as {!Ephemeron.K1.blit_data} *)
234251

@@ -256,28 +273,37 @@ module Kn : sig
256273

257274
val get_key: ('k,'d) t -> int -> 'k option
258275
(** Same as {!Ephemeron.K1.get_key} *)
276+
259277
val get_key_copy: ('k,'d) t -> int -> 'k option
260278
(** Same as {!Ephemeron.K1.get_key_copy} *)
279+
261280
val set_key: ('k,'d) t -> int -> 'k -> unit
262281
(** Same as {!Ephemeron.K1.set_key} *)
282+
263283
val unset_key: ('k,'d) t -> int -> unit
264284
(** Same as {!Ephemeron.K1.unset_key} *)
285+
265286
val check_key: ('k,'d) t -> int -> bool
266287
(** Same as {!Ephemeron.K1.check_key} *)
267288

268-
val blit_key : ('k,_) t -> int -> ('k,_) t -> int -> int -> unit
289+
val blit_key: ('k,_) t -> int -> ('k,_) t -> int -> int -> unit
269290
(** Same as {!Ephemeron.K1.blit_key} *)
270291

271292
val get_data: ('k,'d) t -> 'd option
272293
(** Same as {!Ephemeron.K1.get_data} *)
294+
273295
val get_data_copy: ('k,'d) t -> 'd option
274296
(** Same as {!Ephemeron.K1.get_data_copy} *)
297+
275298
val set_data: ('k,'d) t -> 'd -> unit
276299
(** Same as {!Ephemeron.K1.set_data} *)
300+
277301
val unset_data: ('k,'d) t -> unit
278302
(** Same as {!Ephemeron.K1.unset_data} *)
303+
279304
val check_data: ('k,'d) t -> bool
280305
(** Same as {!Ephemeron.K1.check_data} *)
306+
281307
val blit_data: ('k,'d) t -> ('k,'d) t -> unit
282308
(** Same as {!Ephemeron.K1.blit_data} *)
283309

@@ -307,11 +333,13 @@ module GenHashTable: sig
307333
sig
308334
type t
309335
(** keys *)
336+
310337
type 'a container
311338
(** contains keys and the associated data *)
312339

313340
val hash: int -> t -> int
314341
(** same as {!Hashtbl.SeededHashedType} *)
342+
315343
val equal: 'a container -> t -> equal
316344
(** equality predicate used to compare a key with the one in a
317345
container. Can return [EDead] if the keys in the container are
@@ -320,12 +348,16 @@ module GenHashTable: sig
320348
val create: t -> 'a -> 'a container
321349
(** [create key data] creates a container from
322350
some initials keys and one data *)
351+
323352
val get_key: 'a container -> t option
324353
(** [get_key cont] returns the keys if they are all alive *)
354+
325355
val get_data: 'a container -> 'a option
326356
(** [get_data cont] return the data if it is alive *)
357+
327358
val set_key_data: 'a container -> t -> 'a -> unit
328359
(** [set_key_data cont] modify the key and data *)
360+
329361
val check_key: 'a container -> bool
330362
(** [check_key cont] checks if all the keys contained in the data
331363
are alive *)

stdlib/filename.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module Win32 = struct
130130
match s.[i] with
131131
| '\"' -> add_bs (2*n+1); Buffer.add_char b '\"'; loop (i+1);
132132
| '\\' -> loop_bs (n+1) (i+1);
133-
| c -> add_bs n; loop i
133+
| _ -> add_bs n; loop i
134134
end
135135
and add_bs n = for _j = 1 to n do Buffer.add_char b '\\'; done
136136
in
@@ -151,7 +151,7 @@ module Win32 = struct
151151
let dir = generic_dirname is_dir_sep current_dir_name path in
152152
drive ^ dir
153153
let basename s =
154-
let (drive, path) = drive_and_path s in
154+
let (_drive, path) = drive_and_path s in
155155
generic_basename is_dir_sep current_dir_name path
156156
end
157157

stdlib/gc.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ external set : control -> unit = "caml_gc_set"
180180
external minor : unit -> unit = "caml_gc_minor"
181181
(** Trigger a minor collection. *)
182182

183-
external major_slice : int -> int = "caml_gc_major_slice";;
183+
external major_slice : int -> int = "caml_gc_major_slice"
184184
(** [major_slice n]
185185
Do a minor collection and a slice of major collection. [n] is the
186186
size of the slice: the GC will do enough work to free (on average)
@@ -290,7 +290,7 @@ val finalise : ('a -> unit) -> 'a -> unit
290290
heap-allocated and non-constant except when the length argument is [0].
291291
*)
292292

293-
val finalise_release : unit -> unit;;
293+
val finalise_release : unit -> unit
294294
(** A finalisation function may call [finalise_release] to tell the
295295
GC that it can launch the next finalisation function without waiting
296296
for the current one to return. *)

stdlib/genlex.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,18 @@ let make_lexer keywords =
184184
match Stream.peek strm__ with
185185
Some '(' -> Stream.junk strm__; maybe_nested_comment strm__
186186
| Some '*' -> Stream.junk strm__; maybe_end_comment strm__
187-
| Some c -> Stream.junk strm__; comment strm__
187+
| Some _ -> Stream.junk strm__; comment strm__
188188
| _ -> raise Stream.Failure
189189
and maybe_nested_comment (strm__ : _ Stream.t) =
190190
match Stream.peek strm__ with
191191
Some '*' -> Stream.junk strm__; let s = strm__ in comment s; comment s
192-
| Some c -> Stream.junk strm__; comment strm__
192+
| Some _ -> Stream.junk strm__; comment strm__
193193
| _ -> raise Stream.Failure
194194
and maybe_end_comment (strm__ : _ Stream.t) =
195195
match Stream.peek strm__ with
196196
Some ')' -> Stream.junk strm__; ()
197197
| Some '*' -> Stream.junk strm__; maybe_end_comment strm__
198-
| Some c -> Stream.junk strm__; comment strm__
198+
| Some _ -> Stream.junk strm__; comment strm__
199199
| _ -> raise Stream.Failure
200200
in
201-
fun input -> Stream.from (fun count -> next_token input)
201+
fun input -> Stream.from (fun _count -> next_token input)

0 commit comments

Comments
 (0)