Organisationsocaml-ppxocamlformatdb1b40

Fix formatting oscillation with if-then-else=fit-or-vertical and begin...end When `if-then-else=fit-or-vertical` formats a branch containing `begin (* long comment *) if ... then ... end`, comments between the `then` keyword and `begin` would get attached to different AST locations on each formatting pass ("after" the keyword vs "before" the begin...end expression). This caused `branch_pro` to compute different indentation each time, producing an infinite oscillation that triggered "BUG: formatting did not stabilize after 10 iterations". The fix has two parts: 1. In Fmt_ast, when the if-then-else branch is a special begin...end (wrapping match/try/function/ifthenelse), relocate "after keyword" comments to "before branch" before formatting. This ensures consistent comment placement regardless of source layout. 2. In Params, when computing branch_pro for Fit_or_vertical, also check for comments before the inner expression of a special begin...end, not just before the begin...end node itself. A new helper `Cmts.relocate_after_to_before` moves comments from the "after" position of one location to the "before" position of another.

Apr 25 17:25 +00:00
3m08s
*Variants labelled (experimental) are still undergoing testing; if they have failed it may be a bug in OCaml-CI.