Using "with sexp" for a type generates "Warning 4: this pattern matching is fragile"

I just started using the syntax extension with sexp(described here and here ) for my custom types. However, I noticed that when I do this, I get the following warning about my type:

Warning 4: this pattern-matching is fragile. It will remain exhaustive when constructors are added to type Sexplib.Type.t.

I assume that this is due to the fact that the converters sexp, generated syntax with sexpis treated only type constructors defined for Sexp ( Sexp.Listand Sexp.Atom).

I usually try to fix any warnings in my compilation; is there any way to make the compiler happy here (except that it completely disables the warning for all cases)?

EDIT: for markdown formatting.

Update: Providing example code from hit.ml.

open Core.Std
open Option.Monad_infix

open Battey.Kernel

type hit = (sentence * int) with sexp

Generates this warning:

File "hit.ml", line 6, characters 5-27: Warning 4: this pattern-matching is fragile. It will remain exhaustive when constructors are added to type Sexplib.Type.t.

Additional Information: I am using ocamlc version 4.02.3 (installed via opam) on macbook (Yosemite) and I am using version 113.00.00 from coreand core_kernel. I also use -w Afor my flags.

Sorry for the delay in updating; the holidays kept me away from my laptop / internet connection.

Thanks for the feedback!

+4
source share
1 answer

I believe this is caused by using something like

match t with
| A -> 0
| B -> 1
| _ -> 2

, type t = A | B | C. D, , , . , -, , .

0

Source: https://habr.com/ru/post/1621886/


All Articles