Skip to content

Commit 1d35487

Browse files
committed
Fix extra whitespace got deleted by editor and run ocamlformat
1 parent 24f096f commit 1d35487

File tree

4 files changed

+36
-32
lines changed

4 files changed

+36
-32
lines changed

jscomp/syntax/src/res_core.ml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,28 +3937,32 @@ and parseArrayExp p =
39373937
[] exprs
39383938
in
39393939
let listExprsRev =
3940-
parseCommaDelimitedReversedList p ~grammar:Grammar.ExprList ~closing:Rbracket
3941-
~f:parseSpreadExprRegionWithLoc
3940+
parseCommaDelimitedReversedList p ~grammar:Grammar.ExprList
3941+
~closing:Rbracket ~f:parseSpreadExprRegionWithLoc
39423942
in
39433943
Parser.expect Rbracket p;
39443944
let loc = mkLoc startPos p.prevEndPos in
3945-
let collectExprs = function
3945+
let collectExprs = function
39463946
| [], Some spread, _startPos, _endPos -> [spread]
3947-
| exprs, Some spread, _startPos, _endPos -> (
3947+
| exprs, Some spread, _startPos, _endPos ->
3948+
let els = Ast_helper.Exp.array ~loc exprs in
3949+
[els; spread]
3950+
| exprs, None, _startPos, _endPos ->
39483951
let els = Ast_helper.Exp.array ~loc exprs in
3949-
[els; spread])
3950-
| exprs, None, _startPos, _endPos -> (
3951-
let els = Ast_helper.Exp.array ~loc exprs
3952-
in [els])
3952+
[els]
39533953
in
39543954
match split_by_spread listExprsRev with
39553955
| [] -> Ast_helper.Exp.array ~loc:(mkLoc startPos p.prevEndPos) []
3956-
| [(exprs, None, _, _)] -> Ast_helper.Exp.array ~loc:(mkLoc startPos p.prevEndPos) exprs
3956+
| [(exprs, None, _, _)] ->
3957+
Ast_helper.Exp.array ~loc:(mkLoc startPos p.prevEndPos) exprs
39573958
| exprs ->
39583959
let xs = List.map collectExprs exprs in
3959-
let listExprs = List.fold_right (fun exprs1 acc ->
3960-
List.fold_right (fun expr1 acc1 -> expr1::acc1) exprs1 acc
3961-
) xs [] in
3960+
let listExprs =
3961+
List.fold_right
3962+
(fun exprs1 acc ->
3963+
List.fold_right (fun expr1 acc1 -> expr1 :: acc1) exprs1 acc)
3964+
xs []
3965+
in
39623966
Ast_helper.Exp.apply ~loc
39633967
(Ast_helper.Exp.ident ~loc ~attrs:[spreadAttr]
39643968
(Location.mkloc
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
Syntax error!
3-
jscomp/syntax/tests/parsing/errors/other/spread.res:1:6-8
3+
tests/parsing/errors/other/spread.res:1:6-8
44

55
1 │ let [...arr, _] = [1, 2, 3]
6-
2 │
6+
2 │
77
3 │ let record = {...x, ...y}
88

99
Array's `...` spread is not supported in pattern matches.
@@ -12,25 +12,25 @@ Solution: if it's to validate the first few elements, use a `when` clause + Arra
1212

1313

1414
Syntax error!
15-
jscomp/syntax/tests/parsing/errors/other/spread.res:3:21-23
15+
tests/parsing/errors/other/spread.res:3:21-23
1616

1717
1 │ let [...arr, _] = [1, 2, 3]
18-
2 │
18+
2 │
1919
3 │ let record = {...x, ...y}
2020
4 │ let {...x, ...y} = myRecord
21-
5 │
21+
5 │
2222

2323
Records can only have one `...` spread, at the beginning.
2424
Explanation: since records have a known, fixed shape, a spread like `{a, ...b}` wouldn't make sense, as `b` would override every field of `a` anyway.
2525

2626

2727
Syntax error!
28-
jscomp/syntax/tests/parsing/errors/other/spread.res:4:15-18
28+
tests/parsing/errors/other/spread.res:4:15-18
2929

30-
2 │
30+
2 │
3131
3 │ let record = {...x, ...y}
3232
4 │ let {...x, ...y} = myRecord
33-
5 │
33+
5 │
3434
6 │ let list{...x, ...y} = myList
3535

3636
Record's `...` spread is not supported in pattern matches.
@@ -39,26 +39,26 @@ Solution: you need to pull out each field you want explicitly.
3939

4040

4141
Syntax error!
42-
jscomp/syntax/tests/parsing/errors/other/spread.res:6:13-22
42+
tests/parsing/errors/other/spread.res:6:13-22
4343

4444
4 │ let {...x, ...y} = myRecord
45-
5 │
45+
5 │
4646
6 │ let list{...x, ...y} = myList
47-
7 │
47+
7 │
4848
8 │ type t = {...a}
4949

5050
List pattern matches only supports one `...` spread, at the end.
5151
Explanation: a list spread at the tail is efficient, but a spread in the middle would create new lists; out of performance concern, our pattern matching currently guarantees to never create new intermediate data.
5252

5353

5454
Syntax error!
55-
jscomp/syntax/tests/parsing/errors/other/spread.res:9:20
55+
tests/parsing/errors/other/spread.res:9:20
5656

57-
7 │
57+
7 │
5858
8 │ type t = {...a}
5959
9 │ type t = Foo({...a})
6060
10 │ type t = option<foo, {...x}>
61-
11 │
61+
11 │
6262

6363
I'm not sure what to parse here when looking at ")".
6464

@@ -69,5 +69,5 @@ let x::y = myList
6969
type nonrec t = {
7070
...: a }
7171
type nonrec t =
72-
| Foo of < a >
73-
type nonrec t = (foo, < x > ) option
72+
| Foo of < a >
73+
type nonrec t = (foo, < x > ) option

jscomp/syntax/tests/parsing/grammar/expressions/expected/array.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ let x = ((Belt.Array.concatMany)[@res.spread ]) [|[|4;5|];y|]
55
let x = ((Belt.Array.concatMany)[@res.spread ]) [|[|4;5|];y;[|7|];y|]
66
let x = ((Belt.Array.concatMany)[@res.spread ]) [|[|4;5|];(y : int array)|]
77
let x = ((Belt.Array.concatMany)[@res.spread ]) [|[|4;5;k|];y|]
8-
let x = ((Belt.Array.concatMany)[@res.spread ]) [|y|]
8+
let x = ((Belt.Array.concatMany)[@res.spread ]) [|y|]

jscomp/syntax/tests/parsing/recovery/expression/expected/list.res.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Syntax error!
3-
jscomp/syntax/tests/parsing/recovery/expression/list.res:6:26-28
3+
tests/parsing/recovery/expression/list.res:6:26-28
44

55
4 ┆ let rec loop = (items) => {
66
5 ┆ switch(items) {
@@ -14,7 +14,7 @@ Solution: if it's to validate the first few elements, use a `when` clause + Arra
1414

1515

1616
Syntax error!
17-
jscomp/syntax/tests/parsing/recovery/expression/list.res:7:13-15
17+
tests/parsing/recovery/expression/list.res:7:13-15
1818

1919
5 ┆ switch(items) {
2020
6 ┆ | ["-pp", _ppFlag, ...rest] => loop(rest)
@@ -40,4 +40,4 @@ let flags =
4040
(loop parts) |> (String.concat {js| |js}))
4141
[@res.braces ])
4242
else flags)
43-
[@res.ternary ])
43+
[@res.ternary ])

0 commit comments

Comments
 (0)