File tree Expand file tree Collapse file tree 7 files changed +214
-4
lines changed
recovery/pattern/expected Expand file tree Collapse file tree 7 files changed +214
-4
lines changed Original file line number Diff line number Diff line change 31
31
- Fix attribute printing. https://github.com/rescript-lang/rescript-compiler/pull/7025
32
32
- Fix "rescript format" with many files. https://github.com/rescript-lang/rescript-compiler/pull/7081
33
33
- Fix bigint max, min https://github.com/rescript-lang/rescript-compiler/pull/7088
34
+ - Fix parsing issue with nested variant pattern type spreads. https://github.com/rescript-lang/rescript-compiler/pull/7080
34
35
35
36
#### :nail_care : Polish
36
37
Original file line number Diff line number Diff line change @@ -171,7 +171,8 @@ let is_structure_item_start = function
171
171
let is_pattern_start = function
172
172
| Token. Int _ | Float _ | String _ | Codepoint _ | Backtick | True | False
173
173
| Minus | Plus | Lparen | Lbracket | Lbrace | List | Dict | Underscore
174
- | Lident _ | Uident _ | Hash | Exception | Percent | Module | At ->
174
+ | DotDotDot | Lident _ | Uident _ | Hash | Exception | Percent | Module | At
175
+ ->
175
176
true
176
177
| _ -> false
177
178
Original file line number Diff line number Diff line change
1
+ type nonrec a =
2
+ | One
3
+ | Two
4
+ | Three
5
+ type nonrec b =
6
+ | ... of a
7
+ | Four
8
+ | Five
9
+ type nonrec c =
10
+ | Six
11
+ | Seven
12
+ type nonrec d =
13
+ | ... of b
14
+ | ... of c
15
+ let doWithA =
16
+ ((Function$
17
+ (fun (a : a) ->
18
+ ((match a with
19
+ | One -> Js.log {js|aaa|js}
20
+ | Two -> Js.log {js|twwwoooo|js}
21
+ | Three -> Js.log {js|threeeee|js})
22
+ [@res.braces ])))
23
+ [@res.arity 1])
24
+ let doWithB =
25
+ ((Function$
26
+ (fun (b : b) ->
27
+ ((match b with
28
+ | One -> Js.log {js|aaa|js}
29
+ | _ -> Js.log {js|twwwoooo|js})
30
+ [@res.braces ])))
31
+ [@res.arity 1])
32
+ let lookup =
33
+ ((Function$
34
+ (fun (b : b) ->
35
+ match b with
36
+ | ((#a)[@res.patVariantSpread ]) as a -> doWithA a
37
+ | Four -> Js.log {js|four|js}
38
+ | Five -> Js.log {js|five|js}))
39
+ [@res.arity 1])
40
+ let lookup2 =
41
+ ((Function$
42
+ (fun (d : d) ->
43
+ match d with
44
+ | ((#a)[@res.patVariantSpread ]) as a -> doWithA a
45
+ | ((#b)[@res.patVariantSpread ]) as b -> doWithB b
46
+ | Six|Seven -> Js.log {js|Got rest of d|js}))
47
+ [@res.arity 1])
48
+ let lookupOpt =
49
+ ((Function$
50
+ (fun (b : b option) ->
51
+ match b with
52
+ | Some (((#a)[@res.patVariantSpread ]) as a) -> doWithA a
53
+ | Some (Four) -> Js.log {js|four|js}
54
+ | Some (Five) -> Js.log {js|five|js}
55
+ | None -> Js.log {js|None|js}))
56
+ [@res.arity 1])
57
+ module Foo =
58
+ struct
59
+ type nonrec zz =
60
+ | First
61
+ | Second
62
+ type nonrec xx =
63
+ | ... of zz
64
+ | Third
65
+ end
66
+ let doWithZ =
67
+ ((Function$
68
+ (fun (z : Foo.zz) ->
69
+ match z with
70
+ | First -> Js.log {js|First|js}
71
+ | Second -> Js.log {js|Second|js}))
72
+ [@res.arity 1])
73
+ let lookup3 =
74
+ ((Function$
75
+ (fun (d : Foo.xx) ->
76
+ match d with
77
+ | ((#Foo.zz)[@res.patVariantSpread ]) as z -> Js.log z
78
+ | Third -> Js.log {js|Third|js}))
79
+ [@res.arity 1])
Original file line number Diff line number Diff line change
1
+ type a = One | Two | Three
2
+ type b = | ... a | Four | Five
3
+ type c = Six | Seven
4
+ type d = | ... b | ... c
5
+
6
+ let doWithA = (a : a ) => {
7
+ switch a {
8
+ | One => Js .log ("aaa" )
9
+ | Two => Js .log ("twwwoooo" )
10
+ | Three => Js .log ("threeeee" )
11
+ }
12
+ }
13
+
14
+ let doWithB = (b : b ) => {
15
+ switch b {
16
+ | One => Js .log ("aaa" )
17
+ | _ => Js .log ("twwwoooo" )
18
+ }
19
+ }
20
+
21
+ let lookup = (b : b ) =>
22
+ switch b {
23
+ | ... a as a => doWithA (a )
24
+ | Four => Js .log ("four" )
25
+ | Five => Js .log ("five" )
26
+ }
27
+
28
+ let lookup2 = (d : d ) =>
29
+ switch d {
30
+ | ... a as a => doWithA (a )
31
+ | ... b as b => doWithB (b )
32
+ | Six | Seven => Js .log ("Got rest of d" )
33
+ }
34
+
35
+ let lookupOpt = (b : option <b >) =>
36
+ switch b {
37
+ | Some (... a as a ) => doWithA (a )
38
+ | Some (Four ) => Js .log ("four" )
39
+ | Some (Five ) => Js .log ("five" )
40
+ | None => Js .log ("None" )
41
+ }
42
+
43
+
44
+ module Foo = {
45
+ type zz = First | Second
46
+ type xx = | ... zz | Third
47
+ }
48
+
49
+ let doWithZ = (z : Foo .zz ) =>
50
+ switch z {
51
+ | First => Js .log ("First" )
52
+ | Second => Js .log ("Second" )
53
+ }
54
+
55
+ let lookup3 = (d : Foo .xx ) =>
56
+ switch d {
57
+ | ... Foo .zz as z => Js .log (z )
58
+ | Third => Js .log ("Third" )
59
+ }
Original file line number Diff line number Diff line change 24
24
25
25
26
26
Syntax error!
27
- tests/parsing/recovery/pattern/list.res:4:13
27
+ tests/parsing/recovery/pattern/list.res:4:9-11
28
28
29
29
2 │ | list{} => ()
30
30
3 │ | list{1, list{} => ()
31
31
4 │ | list{}...1, ...list{3, 4} => ()
32
32
5 │ }
33
33
6 │
34
34
35
- I'm not sure what to parse here when looking at ",".
35
+ Did you forget a `}` here?
36
36
37
- ;;match x with | [] -> () | 1::[]::[] -> () | [] -> 1
37
+ ;;match x with | [] -> () | 1::[]::[] -> () | [] -> [%rescript.exprhole ]
38
+ ;;1
38
39
;;[3; 4]
39
40
;;()
Original file line number Diff line number Diff line change @@ -31,3 +31,28 @@ let lookup2 = (d: d) =>
31
31
| ... b as b => doWithB (b )
32
32
| Six | Seven => Js .log ("Got rest of d" )
33
33
}
34
+
35
+ let lookupOpt = (b : option <b >) =>
36
+ switch b {
37
+ | Some (... a as a ) => doWithA (a )
38
+ | Some (Four ) => Js .log ("four" )
39
+ | Some (Five ) => Js .log ("five" )
40
+ | None => Js .log ("None" )
41
+ }
42
+
43
+ module Foo = {
44
+ type zz = First | Second
45
+ type xx = | ... zz | Third
46
+ }
47
+
48
+ let doWithZ = (z : Foo .zz ) =>
49
+ switch z {
50
+ | First => Js .log ("First" )
51
+ | Second => Js .log ("Second" )
52
+ }
53
+
54
+ let lookup3 = (d : Foo .xx ) =>
55
+ switch d {
56
+ | ... Foo .zz as z => Js .log (z )
57
+ | Third => Js .log ("Third" )
58
+ }
You can’t perform that action at this time.
0 commit comments