File tree 6 files changed +79
-3
lines changed
6 files changed +79
-3
lines changed Original file line number Diff line number Diff line change @@ -904,6 +904,21 @@ let parseCommaDelimitedRegion p ~grammar ~closing ~f =
904
904
loop (node::nodes)
905
905
| token when token = closing || token = Eof ->
906
906
List. rev (node::nodes)
907
+ | _ when Grammar. isListElement grammar p.token ->
908
+ (* missing comma between nodes in the region and the current token
909
+ * looks like the start of something valid in the current region.
910
+ * Example:
911
+ * type student<'extraInfo> = {
912
+ * name: string,
913
+ * age: int
914
+ * otherInfo: 'extraInfo
915
+ * }
916
+ * There is a missing comma between `int` and `otherInfo`.
917
+ * `otherInfo` looks like a valid start of the record declaration.
918
+ * We report the error here and then continue parsing the region.
919
+ *)
920
+ Parser. expect Comma p;
921
+ loop (node::nodes)
907
922
| _ ->
908
923
if not (p.token = Eof || p.token = closing || Recover. shouldAbortListParse p) then
909
924
Parser. expect Comma p;
@@ -934,6 +949,21 @@ let parseCommaDelimitedReversedList p ~grammar ~closing ~f =
934
949
loop (node::nodes)
935
950
| token when token = closing || token = Eof ->
936
951
(node::nodes)
952
+ | _ when Grammar. isListElement grammar p.token ->
953
+ (* missing comma between nodes in the region and the current token
954
+ * looks like the start of something valid in the current region.
955
+ * Example:
956
+ * type student<'extraInfo> = {
957
+ * name: string,
958
+ * age: int
959
+ * otherInfo: 'extraInfo
960
+ * }
961
+ * There is a missing comma between `int` and `otherInfo`.
962
+ * `otherInfo` looks like a valid start of the record declaration.
963
+ * We report the error here and then continue parsing the region.
964
+ *)
965
+ Parser. expect Comma p;
966
+ loop (node::nodes)
937
967
| _ ->
938
968
if not (p.token = Eof || p.token = closing || Recover. shouldAbortListParse p) then
939
969
Parser. expect Comma p;
Original file line number Diff line number Diff line change @@ -14,6 +14,42 @@ exports[`patternMatching.js 1`] = `
14
14
Pattern matching needs at least one case
15
15
16
16
17
+ ========================================================"
18
+ ` ;
19
+
20
+ exports [` regionMissingComma.res 1` ] = `
21
+ "=====Parsetree==========================================
22
+ external make :
23
+ ?style:ReactDOMRe.Style.t -> ((?image:bool -> React.element)[@bs ]) =
24
+ \\ "ModalContent\\ "
25
+ type nonrec 'extraInfo student =
26
+ {
27
+ name : string ;
28
+ age : int ;
29
+ otherInfo : ' extraInfo }
30
+ ===== Errors =============================================
31
+
32
+ Syntax error !
33
+ parsing / errors / other / regionMissingComma .res 2 :31
34
+ 1 │ external make : (
35
+ 2 │ ~ style : ReactDOMRe .Style .t = ? .
36
+ 3 │ ~ image : bool = ? ,
37
+ 4 │ ) => React .element = \\" ModalContent\\ "
38
+
39
+ Did you forget a \` ,\` here?
40
+
41
+ Syntax error!
42
+ parsing/errors/other/regionMissingComma.res 8:11-9:11
43
+ 6 │ type student<'extraInfo> = {
44
+ 7 │ name : string ,
45
+ 8 │ age : int
46
+ 9 │ otherInfo : ' extraInfo
47
+ 10 │ }
48
+ 11 │
49
+
50
+ Did you forget a \` ,\` here?
51
+
52
+
17
53
========================================================"
18
54
` ;
19
55
Original file line number Diff line number Diff line change
1
+ external make : (
2
+ ~style : ReactDOMRe .Style .t = ?.
3
+ ~image : bool = ?,
4
+ ) => React .element = "ModalContent"
5
+
6
+ type student <'extraInfo > = {
7
+ name : string ,
8
+ age : int
9
+ otherInfo : 'extraInfo
10
+ }
Original file line number Diff line number Diff line change 35
35
// Pmod_functor
36
36
/* c0 */ module /* c1 */ F /* c2 */ = /* before parameters */ (
37
37
/* c3 */ A /* c4 */ : /* c5 */ X /* c6 */ ,
38
- /* c7 */ B /* c8 */ : /* c9 */ Y /* c 10 */
38
+ /* c7 */ B /* c8 */ : /* c9 */ Y /* c 10 */ ,
39
39
/* c7 */ C /* c8 */ : /* c9 */ Z /* c 10 */
40
40
) => /* c11 */ ReturnMod /* c12 */
41
41
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ let x = Extension.Type.\"type"
3
3
4
4
let \"+++" = ( a , b ) => a + b
5
5
6
- \"+++" ( ~ a = \"let ", \"module" ~ \"type ")
6
+ \"+++" ( ~ a = \"let ", \"module" , ~ \"type ")
7
7
8
8
switch \"type" {
9
9
| ( ) => ( )
Original file line number Diff line number Diff line change 1
1
import {
2
2
@disableGc @disableJit
3
3
delimiter : string ,
4
- cwd as currentWorkingDirectory : unit => string
4
+ cwd as currentWorkingDirectory : unit => string ,
5
5
isAbsolute : string => bool ,
6
6
toNamespacedPath as \"ToNamespacedPath" : string => string ,
7
7
} from "path"
You can’t perform that action at this time.
0 commit comments