Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit 2ccf916

Browse files
committed
Issue with single optional field with attributes.
Add test. Multiple fields works fine. See: #627
1 parent cbc5e69 commit 2ccf916

File tree

2 files changed

+14
-40
lines changed

2 files changed

+14
-40
lines changed
Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,10 @@
1-
let r = { a = expr }
2-
let r = { a = expr }
3-
let r = { Parsetree.pexp_attributes = [||]; Parsetree.loc = loc }
4-
let r = { a; b; c }
5-
let r = { A.a = a; b }
6-
let r = { A.a = a; b; C.c = c }
7-
let r = { Parsetree.pexp_attributes = pexp_attributes; Parsetree.loc = loc }
8-
let r = { Parsetree.pexp_attributes = pexp_attributes; Parsetree.loc = loc }
9-
let r = { a = (expr : int); b = (x : string) }
10-
let r = { expr with pexp_attributes = [||] }
11-
let r = { expr with pexp_attributes = [||]; pexp_loc = loc }
12-
let r = { expr with pexp_attributes = [||] }
13-
let r = { (make () : myRecord) with foo = bar }
14-
let r = { (make () : myRecord) with foo = bar }
15-
let r =
16-
{
17-
x = ((None)[@ns.optional ]);
18-
y = ((None)[@ns.optional ]);
19-
z = (((None : tt))[@ns.optional ])
20-
}
21-
let z name = { name = ((name)[@ns.optional ]); x = 3 }
22-
let z name = { name = ((name)[@ns.optional ]); x = 3 }
23-
let z name = { name; x = ((x)[@ns.optional ]) }
24-
let zz name = { name; x = ((x)[@ns.optional ]) }
25-
let _ =
26-
match z with
27-
| { x = ((None)[@ns.optional ]); y = ((None)[@ns.optional ]);
28-
z = (((None : tt))[@ns.optional ]) } -> 11
29-
| { name = ((name)[@ns.optional ]); x = 3 } -> 42
30-
| { name = ((name)[@ns.optional ]); x = 3 } -> 4242
31-
| { x = ((None)[@ns.optional ]); y = ((None)[@ns.optional ]);
32-
z = (((None : tt))[@ns.optional ]) } -> 11
33-
| { name = ((name)[@ns.optional ]); x = 3 } -> 42
34-
| { name = ((name)[@ns.optional ]); x = 3 } -> 4242
35-
type nonrec tt = {
36-
x: int ;
37-
y: string [@ns.opttinal ]}
38-
type nonrec ttt = {
39-
x: int ;
40-
y: string [@ns.optional ]}
1+
2+
Syntax error!
3+
tests/parsing/grammar/expressions/record.res:52:32
4+
5+
50 │ type multipleWithAttrs = {x:int, @attr y?: string}
6+
51 │
7+
52 │ type singleWithAttrs = {@attr y?: string}
8+
9+
I'm not sure what to parse here when looking at "?".
10+

tests/parsing/grammar/expressions/record.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,7 @@ let _ = switch z {
4646
type tt = {x:int, @ns.opttinal y : string}
4747

4848
type ttt = {x:int, y?: string}
49+
50+
type multipleWithAttrs = {x:int, @attr y?: string}
51+
52+
type singleWithAttrs = {@attr y?: string}

0 commit comments

Comments
 (0)