diff --git a/test/passing/tests/modes_cmts_move.ml b/test/passing/tests/modes_cmts_move.ml index 0ea2471a4f..2c8abc89ca 100644 --- a/test/passing/tests/modes_cmts_move.ml +++ b/test/passing/tests/modes_cmts_move.ml @@ -1,4 +1,20 @@ +(* This comment moves for similar reason to existing behavior as shown below. + In particular, the operator ([@@] / [->]) does not carry a source locaion, + and the comment attaches to the location of the identifier on the right side + of the operator rather than the left due to the parenthesis. Fixing this would + require messing with the comment association logic, which is difficult. *) type t = A of t1 @@ m1 m2 * t2 @@ m3 m4 * (t3 @ m5 -> t4 @ m6) (* cmt *) @@ m7 m8 +type t = A of (t -> u) (* cmt *) @@ m +type t = A of ((t -> u) (* cmt *) -> m) +(* This comment attaches to the [f]; the syntax [(f @ mode1)] doesn't have its own + location to latch onto. This seems like a rare position to put a comment, so it doesn't + seem worth changing the parser to be able to differentiate the following two. *) let (* cmt *) (f @ mode1) (arg1 @ mode2) (arg2 @ mode3) : typ = x +let (* cmt *) (f @ mode) arg = x +let ((* cmt *) f @ mode) arg = x + +(* This comment moves due to existing behavior as shown below. *) let (f @ mode1) (arg1 @ mode2) (arg2 @ mode3) (* cmt *) : typ = x +let f (arg @ mode) (* cmt *) : typ = x +let f (arg : typ) (* cmt *) : typ = x diff --git a/test/passing/tests/modes_cmts_move.ml.js-ref b/test/passing/tests/modes_cmts_move.ml.js-ref index 97cb66e11a..a00e3f0dc8 100644 --- a/test/passing/tests/modes_cmts_move.ml.js-ref +++ b/test/passing/tests/modes_cmts_move.ml.js-ref @@ -1,4 +1,20 @@ +(* This comment moves for similar reason to existing behavior as shown below. + In particular, the operator ([@@] / [->]) does not carry a source locaion, + and the comment attaches to the location of the identifier on the right side + of the operator rather than the left due to the parenthesis. Fixing this would + require messing with the comment association logic, which is difficult. *) type t = A of t1 @@ m1 m2 * t2 @@ m3 m4 * (t3 @ m5 -> t4 @ m6) @@ (* cmt *) m7 m8 +type t = A of (t -> u) @@ (* cmt *) m +type t = A of ((t -> u) -> (* cmt *) m) +(* This comment attaches to the [f]; the syntax [(f @ mode1)] doesn't have its own + location to latch onto. This seems like a rare position to put a comment, so it doesn't + seem worth changing the parser to be able to differentiate the following two. *) let ((* cmt *) f @ mode1) (arg1 @ mode2) (arg2 @ mode3) : typ = x +let ((* cmt *) f @ mode) arg = x +let ((* cmt *) f @ mode) arg = x + +(* This comment moves due to existing behavior as shown below. *) let (f @ mode1) (arg1 @ mode2) (arg2 @ mode3) : typ = (* cmt *) x +let f (arg @ mode) : typ = (* cmt *) x +let f (arg : typ) : typ = (* cmt *) x diff --git a/test/passing/tests/modes_cmts_move.ml.ref b/test/passing/tests/modes_cmts_move.ml.ref index 0249b5e2c2..8e24f84890 100644 --- a/test/passing/tests/modes_cmts_move.ml.ref +++ b/test/passing/tests/modes_cmts_move.ml.ref @@ -1,6 +1,29 @@ +(* This comment moves for similar reason to existing behavior as shown below. + In particular, the operator ([@@] / [->]) does not carry a source locaion, + and the comment attaches to the location of the identifier on the right + side of the operator rather than the left due to the parenthesis. Fixing + this would require messing with the comment association logic, which is + difficult. *) type t = | A of t1 @@ m1 m2 * t2 @@ m3 m4 * (t3 @ m5 -> t4 @ m6) @@ (* cmt *) m7 m8 +type t = A of (t -> u) @@ (* cmt *) m + +type t = A of ((t -> u) -> (* cmt *) m) + +(* This comment attaches to the [f]; the syntax [(f @ mode1)] doesn't have + its own location to latch onto. This seems like a rare position to put a + comment, so it doesn't seem worth changing the parser to be able to + differentiate the following two. *) let ((* cmt *) f @ mode1) (arg1 @ mode2) (arg2 @ mode3) : typ = x +let ((* cmt *) f @ mode) arg = x + +let ((* cmt *) f @ mode) arg = x + +(* This comment moves due to existing behavior as shown below. *) let (f @ mode1) (arg1 @ mode2) (arg2 @ mode3) : typ = (* cmt *) x + +let f (arg @ mode) : typ = (* cmt *) x + +let f (arg : typ) : typ = (* cmt *) x