小编use*_*376的帖子

在类型上使用'with sexp'会生成“警告4:此模式匹配很脆弱”

我刚刚开始在我的自定义类型上使用with sexp语法扩展名(此处此处所述)。但是,我注意到当我这样做时,会收到关于我的类型的以下警告:

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

假设这是因为由with sexp语法生成的sexp转换器仅处理为Sexp(Sexp.ListSexp.Atom)定义的类型构造函数。

我通常会尝试修正我的汇编中的所有警告;有没有一种方法可以使编译器在这里满意(除了让它完全抑制所有情况下的警告)?

编辑:降价格式化。

更新:提供来自的示例代码hit.ml

open Core.Std
open Option.Monad_infix

open Battey.Kernel

type hit = (sentence * int) with sexp
Run Code Online (Sandbox Code Playgroud)

生成此警告:

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.

其他信息:我使用ocamlc的4.02.3版本(如通过安装opam …

ocaml pattern-matching compiler-warnings s-expression

5
推荐指数
1
解决办法
242
查看次数