-
Notifications
You must be signed in to change notification settings - Fork 102
Description
The following:
[@@@expand_inline
(** i am bar *)
let bar = 10
]
(** i am foo *)
let foo = 10
[@@@end] Would get corrected to:
[@@@expand_inline
(** i am bar *)
let bar = 10
]
(** i am foo *)
let bar = 10 [@@ocaml.doc {| i am bar |}]
[@@@end] The problem is that the location of structure/signature items do not include the location of attached odoc comments via (** *). Consequently, when ppxlib is deciding which part of the source code to overwrite in a correction file, this ends up not including odoc comments. Note, this is not a bug with [@@@expand_inline] specifically, but for any transformation that registers a correction file (however, this would be extremely unlikely to occur with [@@deriving_inline] unless the user was doing some really funky stuff). A more likely scenario for how one might encounter this bug:
- You wrap some existing code inside an
[@@@expand_inline]block. - You copy that same code into the payload of
[@@@expand_inline]. - You accept the correction and you get something like the above.
Arguably, this is a parser bug. Structure and signature items should include the locations of any attached odoc comments. That being said, this bug is really rare to come across and not urgent to fix imo. I thought I'd just make an issue here to document it.