如何使用[@ ocaml.warning“-30”]隐藏警告30

问题描述 投票:1回答:1

我有两个相互依赖的记录,它们都有一个同名的字段。如何使用ocaml.warning属性隐藏此警告?我想避免像[@@@ocaml.warning "-30"] my types here [@@@ocaml.warning "+30"]这样的东西。

# type a = {a : int;} and b = { a:int;};;
Characters 30-36:
Warning 30: the label a is defined in both types a and b.
type a = { a : int; }
and b = { a : int; }
functional-programming ocaml
1个回答
1
投票

这可能没有你想要避免的包围结构更好,但它对我有用:

# module M = struct
    type a = {a: int} and b = {a: int}
  end [@warning "-30"];;
module M : sig type a = { a : int; } and b = { a : int; } end
# type a = M.a and b = M.b;;
type a = M.a
and b = M.b
© www.soinside.com 2019 - 2024. All rights reserved.