Error (warning 50): ambiguous documentation comment

Viewed 74

Wrote this code in ocaml (compiling with 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

when I say dune build it gives error

Error (warning 50): ambiguous documentation comment

What I don't understand is what is ambiguous about this comment? looks pretty clear to me.

I didn't write this code myself I took this from a YouTube tutorial https://youtu.be/hr8SmQK8ld8

Here is my code https://github.com/abhsrivastava/mymaps.git

1 Answers

Neither the code fragment that you have written nor the code that you linked raises the ambiguous documentation comment warning. Thus I can only guess what is the real source of the error.

However, it is important to notice that the [unexpected-docstring] comment is about an ambiguous location of a documentation comment. It is not about the content of the comment.

For instance, removing a line break in your code,

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

yields

Warning 50 [unexpected-docstring]: ambiguous documentation comment

because it is unclear if the documentation comment should be attached to empty or insert.

The general fix for the unexpected-docstring waring is to update the unknown code that raises the warning by adding line breaks between documentation comments and unrelated signature items.

Related