File tree Expand file tree Collapse file tree 4 files changed +99
-8
lines changed Expand file tree Collapse file tree 4 files changed +99
-8
lines changed Original file line number Diff line number Diff line change 28
28
- Generic JSX transform: Handle namespaced names. https://github.com/rescript-lang/rescript-compiler/pull/6606
29
29
- Fix issue with doc comment in recursive module. https://github.com/rescript-lang/rescript-compiler/pull/6613
30
30
- Fix issue with Exceptions and Extensible types runtime generation. https://github.com/rescript-lang/rescript-compiler/pull/6570
31
+ - Fix inline comment before spread syntax in record. https://github.com/rescript-lang/rescript-compiler/pull/6615
31
32
32
33
#### :house : Internal
33
34
Original file line number Diff line number Diff line change @@ -2964,15 +2964,25 @@ and printExpression ~state (e : Parsetree.expression) cmtTbl =
2964
2964
let spread =
2965
2965
match spreadExpr with
2966
2966
| None -> Doc. nil
2967
- | Some expr ->
2967
+ | Some ({pexp_desc} as expr ) ->
2968
+ let doc =
2969
+ match pexp_desc with
2970
+ | Pexp_ident {txt = expr } -> printLident expr
2971
+ | _ -> printExpression ~state expr cmtTbl
2972
+ in
2973
+ let docWithSpread =
2974
+ Doc. concat
2975
+ [
2976
+ Doc. dotdotdot;
2977
+ (match Parens. expr expr with
2978
+ | Parens. Parenthesized -> addParens doc
2979
+ | Braced braces -> printBraces doc expr braces
2980
+ | Nothing -> doc);
2981
+ ]
2982
+ in
2968
2983
Doc. concat
2969
2984
[
2970
- Doc. dotdotdot;
2971
- (let doc = printExpressionWithComments ~state expr cmtTbl in
2972
- match Parens. expr expr with
2973
- | Parens. Parenthesized -> addParens doc
2974
- | Braced braces -> printBraces doc expr braces
2975
- | Nothing -> doc);
2985
+ printComments docWithSpread cmtTbl expr.Parsetree. pexp_loc;
2976
2986
Doc. comma;
2977
2987
Doc. line;
2978
2988
]
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ let user = /* before */ {
125
125
} // after
126
126
127
127
let spreadUser = {
128
- ... /* before */ user1 /* after */,
128
+ /* before */ ... user1 /* after */,
129
129
/* c0 */ age /* c1 */: /* c2 */ 32 /* c3 */,
130
130
}
131
131
@@ -284,3 +284,43 @@ Doc.concat(list{
284
284
rows,
285
285
/* a */
286
286
})
287
+
288
+ // More record spread test
289
+ type b = {
290
+ // spread a
291
+ ...a,
292
+ // spread c
293
+ ...c,
294
+ // no spread
295
+ b: string,
296
+ }
297
+
298
+ type a = {
299
+ // spread from different module
300
+ ...M.a,
301
+ // spread c
302
+ ...c,
303
+ // no spread
304
+ b: string,
305
+ }
306
+
307
+ let b = {
308
+ // exotic
309
+ ...\"let",
310
+ // foo
311
+ bar: "foo",
312
+ }
313
+
314
+ let b = {
315
+ // quote
316
+ ..."let",
317
+ // foo
318
+ bar: "foo",
319
+ }
320
+
321
+ let c = {
322
+ // from different module
323
+ ...M.a,
324
+ // foo
325
+ bar: "foo",
326
+ }
Original file line number Diff line number Diff line change @@ -275,3 +275,43 @@ Doc.concat(list{
275
275
rows ,
276
276
/* a */
277
277
});
278
+
279
+ // More record spread test
280
+ type b = {
281
+ // spread a
282
+ ... a ,
283
+ // spread c
284
+ ... c ,
285
+ // no spread
286
+ b : string
287
+ }
288
+
289
+ type a = {
290
+ // spread from different module
291
+ ... M .a ,
292
+ // spread c
293
+ ... c ,
294
+ // no spread
295
+ b : string
296
+ }
297
+
298
+ let b = {
299
+ // exotic
300
+ ... \"let" ,
301
+ // foo
302
+ bar : "foo"
303
+ }
304
+
305
+ let b = {
306
+ // quote
307
+ ... "let" ,
308
+ // foo
309
+ bar : "foo"
310
+ }
311
+
312
+ let c = {
313
+ // from different module
314
+ ... M .a ,
315
+ // foo
316
+ bar : "foo"
317
+ }
You can’t perform that action at this time.
0 commit comments