Repository navigation
Commit d7eb937
Keep attributes in front of a labeled parameter alias when formatting (#9111)
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.
Format modified (labeled parameter alias):
Example:
let g = (@attr ~a as x: int) => x
let h = (/** a */ ~a as x: int=3) => x
Before (rescript):
let g = (~a as @attr x: int) => x
let h = (
~a as /** a */
x: int=3,
) => x
After (rescript):
let g = (@attr ~a as x: int) => x
let h = (
/** a */
~a as x: int=3,
) => x
Claude-Session: https://claude.ai/code/session_01Kbf3gGkPma9LAZimuQjnrP
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 4b1fcda commit d7eb937
7 files changed
Lines changed: 26 additions & 5 deletions
File tree
- changes
- compiler/syntax/src
- tests/syntax_tests/data/printer
- comments
- expected
- expr
- expected
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5656 | 5656 | | |
5657 | 5657 | | |
5658 | 5658 | | |
5659 | | - | |
| 5659 | + | |
5660 | 5660 | | |
5661 | 5661 | | |
| 5662 | + | |
5662 | 5663 | | |
5663 | 5664 | | |
5664 | 5665 | | |
5665 | | - | |
| 5666 | + | |
5666 | 5667 | | |
5667 | 5668 | | |
5668 | 5669 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
78 | 85 | | |
79 | 86 | | |
80 | 87 | | |
| |||
0 commit comments