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 2828- Generic JSX transform: Handle namespaced names. https://github.com/rescript-lang/rescript-compiler/pull/6606
2929- Fix issue with doc comment in recursive module. https://github.com/rescript-lang/rescript-compiler/pull/6613
3030- 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
3132
3233#### :house : Internal
3334
Original file line number Diff line number Diff line change @@ -2964,15 +2964,25 @@ and printExpression ~state (e : Parsetree.expression) cmtTbl =
29642964 let spread =
29652965 match spreadExpr with
29662966 | 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
29682983 Doc. concat
29692984 [
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;
29762986 Doc. comma;
29772987 Doc. line;
29782988 ]
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ let user = /* before */ {
125125} // after
126126
127127let spreadUser = {
128- ... /* before */ user1 /* after */,
128+ /* before */ ... user1 /* after */,
129129 /* c0 */ age /* c1 */: /* c2 */ 32 /* c3 */,
130130}
131131
@@ -284,3 +284,43 @@ Doc.concat(list{
284284 rows,
285285 /* a */
286286})
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{
275275 rows ,
276276 /* a */
277277});
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