Troubles using alerts

I’m trying to use alerts to report non-implemented functions as warnings. But my alerts are not shown during compilation. (I think any alerts are not shown on compilation) Where could be an issue?

[@@@alert unsafe "This module is unsafe!"]

module X = struct
  let is_interesting_var _ _ =
    (assert false [@alert not_implemented "Not implemented"])
    [@@deprecated "Not implemented"]

  [@@@ocaml.alert deprecated "Please implement stuff above"]
end

let _ = X.is_interesting_var 1 2
➜  ocamlc  -alert +not_implemented -alert +deprecated -alert +unsafe -alert +all -w +3 -c a.ml   
➜  ocamlc -version                                                                  
4.12.1

I’m not sure that alerts can be attached to implementations that way. In principle they can be attached to signatures:

module X : sig
  val is_interesting_var : _ -> _ -> _
  [@@alert unsafe "xyz"]
end  = struct
  let is_interesting_var _ _ =
    assert false
end [@@ocaml.alert deprecated "Please implement stuff above"]

let _ = X.is_interesting_var 1 2

Moreover, the top-level form [@@@alert ...] is used to toggle specific alerts. See the manual OCaml - Language extensions for more.

Cheers,
Nicolas

2 Likes