This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +78
-1
lines changed
tests/parsing/errors/typeDef Expand file tree Collapse file tree 4 files changed +78
-1
lines changed Original file line number Diff line number Diff line change @@ -4024,6 +4024,14 @@ and parseStringFieldDeclaration p =
4024
4024
Parser. expect ~grammar: Grammar. TypeExpression Colon p;
4025
4025
let typ = parsePolyTypeExpr p in
4026
4026
Some (Parsetree. Otag (fieldName, attrs, typ))
4027
+ | Lident name ->
4028
+ let nameLoc = mkLoc p.startPos p.endPos in
4029
+ Parser. err p (Diagnostics. message " An inline record type declaration is only allowed in a variant constructor's declaration" );
4030
+ Parser. next p;
4031
+ let fieldName = Location. mkloc name nameLoc in
4032
+ Parser. expect ~grammar: Grammar. TypeExpression Colon p;
4033
+ let typ = parsePolyTypeExpr p in
4034
+ Some (Parsetree. Otag (fieldName, attrs, typ))
4027
4035
| _token ->
4028
4036
None
4029
4037
Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ let isParameterStart = function
209
209
210
210
(* TODO: overparse Uident ? *)
211
211
let isStringFieldDeclStart = function
212
- | Token. String _ | At -> true
212
+ | Token. String _ | Lident _ | At -> true
213
213
| _ -> false
214
214
215
215
(* TODO: overparse Uident ? *)
Original file line number Diff line number Diff line change @@ -35,6 +35,56 @@ type nonrec record = {
35
35
A record needs at least one field
36
36
37
37
38
+ ========================================================"
39
+ ` ;
40
+
41
+ exports [` inlineRecord.res 1` ] = `
42
+ "=====Parsetree==========================================
43
+ type nonrec entity =
44
+ | Director
45
+ | Student of
46
+ {
47
+ name : string ;
48
+ reportCard : < passing : bool ;score : int > Js .t }
49
+ type nonrec user =
50
+ {
51
+ name : string ;
52
+ address : < street : string ;country : string > Js .t }
53
+ let make (props : < handleClick: Click.t -> unit ;value: string > Js.t) =
54
+ render props
55
+ =====Errors=============================================
56
+
57
+ Syntax error!
58
+ parsing/errors/typeDef/inlineRecord.res 6:9-15
59
+ 4 ┆ name: string,
60
+ 5 ┆ reportCard: {
61
+ 6 ┆ passing : bool ,
62
+ 7 ┆ score : int
63
+ 8 ┆ }
64
+
65
+ An inline record type declaration is only allowed in a variant constructor's declaration
66
+
67
+ Syntax error!
68
+ parsing/errors/typeDef/inlineRecord.res 14:5-10
69
+ 12 ┆ name: string,
70
+ 13 ┆ address: {
71
+ 14 ┆ street : string ,
72
+ 15 ┆ country : string ,
73
+ 16 ┆ }
74
+
75
+ An inline record type declaration is only allowed in a variant constructor's declaration
76
+
77
+ Syntax error!
78
+ parsing/errors/typeDef/inlineRecord.res 19:21-31
79
+ 17 │ }
80
+ 18 │
81
+ 19 │ let make = (props: { handleClick : Click .t => unit , value : string } ) => r
82
+ ender(props)
83
+ 20 │
84
+
85
+ An inline record type declaration is only allowed in a variant constructor's declaration
86
+
87
+
38
88
========================================================"
39
89
` ;
40
90
Original file line number Diff line number Diff line change
1
+ type entity =
2
+ | Director
3
+ | Student ({
4
+ name : string ,
5
+ reportCard : {
6
+ passing : bool ,
7
+ score : int
8
+ }
9
+ })
10
+
11
+ type user = {
12
+ name : string ,
13
+ address : {
14
+ street : string ,
15
+ country : string ,
16
+ }
17
+ }
18
+
19
+ let make = (props : {handleClick : Click .t => unit , value : string }) => render (props )
You can’t perform that action at this time.
0 commit comments