Keep the comments around a list pattern's only spread when formatting
Why
list{...r} parses to the pattern r itself, but the parser gave that pattern the location of the whole list{...}. A comment around the spread was then inside the location of the leaf r, where comment attachment leaves it unattached, so formatting dropped it. The pattern now keeps the location of r, like list{...e} in expressions, and the comments become leading or trailing comments of r.
modifiedFormat comment around a list pattern's only spread
let f = x => switch x { | list{/* d */ ...r} => r }let g = (list{...r /* t */}) => r
rescript
Before
After
let f = x =>let f = x => switch x { switch x { | r => r /* d */ | r => r } }let g = r => rlet g = r /* t */ => r
Fixes: #9123
Review
- Why is the comment printed before
|? That is where the formatter already puts a leading comment of a case pattern, as for| /* d */ r.