Semantic Diff

#9111 Keep attributes in front of a labeled parameter alias when formatting

1 commit

85f31fbb15ef96bd168d6e99055ad4808810d6e0..pr-9111

1b247dcbf · cknitt + Claude · Oct 28, 2026, 15:25 UTC

Keep attributes in front of a labeled parameter alias when formatting

Why

The parser puts attributes written before ~a as x on the alias pattern, and the formatter printed them after as, where they parse onto the inner pattern, so formatting changed the AST (#9101). Doc comments in that position were printed between as and the pattern.

modifiedFormat labeled parameter alias

let g = (@attr ~a as x: int) => xlet h = (/** a */ ~a as x: int=3) => x
rescript
Before
After
let g = (~a as @attr x: int) => xlet g = (@attr ~a as x: int) => xlet h = (let h = ( ~a as /** a */ x: int=3, /** a */ ~a as x: int=3,) => x) => x