Repository navigation
Commit 2fd7cd9
committed
Make multi-line item spacing the experimental feature MultilineItemSpacing
Why:
Spacing multi-line module items changes the output of `rescript
format` for most existing projects (341 files in this repository
alone), so it is opt-in, like `let?` (LetUnwrap). Without the feature
the formatter prints exactly as before, and the snapshots of the
previous commit return to their master state.
Format modified (multi-line item spacing, opt-in):
Example:
module A = {
let x = 1
}
let y = 2
Before (rescript): always, since the previous commit
module A = {
let x = 1
}
let y = 2
After (rescript): "experimental-features": {"MultilineItemSpacing": true}
module A = {
let x = 1
}
let y = 2
Format unchanged (default):
Example:
module A = {
let x = 1
}
let y = 2
After (rescript): without the feature
module A = {
let x = 1
}
let y = 2
Diagnostic modified (unknown experimental feature):
Example:
"experimental-features": {"FooBar": true}
Before (diagnostic): Unknown experimental feature 'FooBar'. Available features: LetUnwrap
After (diagnostic): Unknown experimental feature 'FooBar'. Available features: LetUnwrap, MultilineItemSpacing
Review: How does `rescript format` learn about the feature? Both build systems pass the root project's experimental flags, the same ones a build passes, to `bsc` before `-format`; `-format` runs as soon as bsc reads it, so the order matters. Outside a project, format runs without them, as before. Covered by rewatch/tests/format/06-format-experimental-multiline-item-spacing.sh, which passes for both rescript.exe and rescript-rust.exe.
Review: How do the syntax tests enable it? `res_parser` accepts `-enable-experimental`, and scripts/test_syntax.sh prints and round-trips each file under tests/syntax_tests/data/experimental/<Feature>/ with that feature enabled.
Review: What about tools that call `bsc -format` directly instead of `rescript format`? They format without the feature unless they pass `-enable-experimental MultilineItemSpacing` before `-format`.
Signed-off-by: Roland Peelen <roland@magic.dev>1 parent e73be3d commit 2fd7cd9
129 files changed
Lines changed: 129 additions & 546 deletions
File tree
- changes
- compiler
- bsc
- ml
- syntax
- cli
- src
- docs/docson
- rewatch-ocaml
- rewatch
- src
- tests
- experimental-invalid
- format
- scripts
- tests/syntax_tests/data
- ast-mapping/expected
- conversion/reason/expected
- experimental/MultilineItemSpacing
- expected
- ppx/react/expected
- printer
- comments/expected
- expected
- expr/expected
- modExpr/expected
- modType/expected
- other/expected
- pattern/expected
- signature/expected
- structure/expected
- typeDef/expected
- typexpr/expected
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
492 | 492 | | |
493 | 493 | | |
494 | 494 | | |
495 | | - | |
| 495 | + | |
| 496 | + | |
496 | 497 | | |
497 | 498 | | |
498 | 499 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
690 | 693 | | |
691 | 694 | | |
692 | 695 | | |
693 | 696 | | |
694 | 697 | | |
695 | | - | |
| 698 | + | |
696 | 699 | | |
697 | 700 | | |
698 | 701 | | |
| |||
1110 | 1113 | | |
1111 | 1114 | | |
1112 | 1115 | | |
1113 | | - | |
| 1116 | + | |
1114 | 1117 | | |
1115 | 1118 | | |
1116 | 1119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
559 | 563 | | |
560 | 564 | | |
561 | 565 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
253 | | - | |
| 253 | + | |
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
120 | 130 | | |
121 | 131 | | |
122 | | - | |
| 132 | + | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
| |||
129 | 140 | | |
130 | 141 | | |
131 | 142 | | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
| |||
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
140 | | - | |
| 152 | + | |
| 153 | + | |
141 | 154 | | |
142 | 155 | | |
143 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
125 | 126 | | |
126 | 127 | | |
127 | 128 | | |
| |||
0 commit comments