Jean
Jean

Reputation: 95

ocaml-top does not compile past (pattern matching) Warning 8

With ocaml-top 1.1.5 and ocaml 4.02.3 on macOS High Sierra:

When compiling a file where a function triggers a (pattern matching) Warning 8, the warning is displayed in red (in the Windows ocaml-top version I usually use it would be yellow) ; the function itself seems to compile and gives a type, but functions below it in the file cannot be compiled (as if the Warning was an actual compilation error).

How can I compile past that? My missing cases are obviously intentional.

EDIT: with no ocaml-top specific answer, I'm just completing all my pattern matchings with _-> failwith "blabla" type statements. Should I use something else than ocaml-top, anything not too hard to install on macOS for somebody who has not idea how package dependency and so on work?

Upvotes: 0

Views: 103

Answers (1)

Jeffrey Scofield
Jeffrey Scofield

Reputation: 66803

Most likely the difference in the two environments is in the compiler options. Warnings (by definition) don't terminate compilation. But each warning (by number) can be made fatal with the -w option like this:

ocamlc -w @8  ...

If you can find this setting you can remove it to get the default treatment for warning 8.

Compiler options are described in Section 8.2 of the OCaml manual.

As @vonaka says, you can also use attributes in the source to turn off a warning for just one function like this:

let [@warning "-8"] myfun x =
    match x with None -> 18

Attributes are described in Section 7.18 of the OCaml manual. Built-in attributes like [@warning ...] are described in section 7.18.1.

Upvotes: 2

Related Questions