错误(警告 50):不明确的文档注释

Error (warning 50): ambiguous documentation comment

用 ocaml 编写这段代码(用 dune 编译)

(** [insert k v m] is the same map as [m], but with an additional 
    binding from [k] to [v]. If [k] was already bound in [m], that 
    binding is replaced by the binding to [v] in the new map. *)
val insert : 'k -> 'v -> ('k, 'v) t -> ('k, 'v) t

当我说 dune build 时出现错误

Error (warning 50): ambiguous documentation comment

我不明白的是这个评论有什么歧义?我看起来很清楚。

这段代码不是我自己写的,我是从 YouTube 教程中获取的 https://youtu.be/hr8SmQK8ld8

这是我的代码https://github.com/abhsrivastava/mymaps.git

您编写的代码片段和链接的代码都没有引发不明确的文档注释警告。因此我只能猜测错误的真正来源是什么。

但是,重要的是要注意 [unexpected-docstring] 注释是关于文档注释的不明确位置。与评论内容无关

例如,删除代码中的换行符,

val empty : ('k, 'v) t
(** [insert k v m] is the same map as [m], but with an additional 
    binding from [k] to [v]. If [k] was already bound in [m], that 
    binding is replaced by the binding to [v] in the new map. *)
val insert : 'k -> 'v -> ('k, 'v) t -> ('k, 'v) t

产量

Warning 50 [unexpected-docstring]: ambiguous documentation comment

因为不清楚文档注释应该附加到empty还是insert

unexpected-docstring 警告的一般修复是通过在文档注释和不相关的签名项之间添加换行符来更新引发警告的未知代码。