This repository was archived by the owner on Jun 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +36
-17
lines changed Expand file tree Collapse file tree 3 files changed +36
-17
lines changed Original file line number Diff line number Diff line change @@ -1682,22 +1682,13 @@ and walkExprArgument (_argLabel, expr) t comments =
1682
1682
recordRows
1683
1683
t
1684
1684
comments
1685
- | Ppat_or (pattern1 , pattern2 ) ->
1686
- let (beforePattern1, insidePattern1, afterPattern1) =
1687
- partitionByLoc comments pattern1.ppat_loc
1688
- in
1689
- attach t.leading pattern1.ppat_loc beforePattern1;
1690
- walkPattern pattern1 t insidePattern1;
1691
- let (afterPattern1, rest) =
1692
- partitionAdjacentTrailing pattern1.ppat_loc afterPattern1
1693
- in
1694
- attach t.trailing pattern1.ppat_loc afterPattern1;
1695
- let (beforePattern2, insidePattern2, afterPattern2) =
1696
- partitionByLoc rest pattern2.ppat_loc
1697
- in
1698
- attach t.leading pattern2.ppat_loc beforePattern2;
1699
- walkPattern pattern2 t insidePattern2;
1700
- attach t.trailing pattern2.ppat_loc afterPattern2
1685
+ | Ppat_or _ ->
1686
+ walkList
1687
+ ~get Loc: (fun pattern -> pattern.Parsetree. ppat_loc)
1688
+ ~walk Node: (fun pattern -> walkPattern pattern)
1689
+ (Res_parsetree_viewer. collectOrPatternChain pat)
1690
+ t
1691
+ comments
1701
1692
| Ppat_constraint (pattern , typ ) ->
1702
1693
let (beforePattern, insidePattern, afterPattern) =
1703
1694
partitionByLoc comments pattern.ppat_loc
Original file line number Diff line number Diff line change @@ -59,7 +59,21 @@ let /* before */ {
59
59
60
60
// Ppat_or
61
61
let /* b1 */ Blue /* b2 */ | /* c1 */ Red /* c2 */ = color
62
- let /* b1 */ Blue /* b2 */ | /* c1 */ Red | /* d1 */ Green /* d2 */ = color
62
+ let /* b1 */ Blue /* b2 */ | /* c1 */ Red /* c2 */ | /* d1 */ Green /* d2 */ = color
63
+
64
+ // #462: Comments in nested Ppat_or must not disappear.
65
+ // (comment positions not optimal yet because `|` has no AST location)
66
+ let _ = switch "anything" {
67
+ // above 1
68
+ | "1"
69
+ | // below 1
70
+ "2"
71
+ | // below 2
72
+ "3"
73
+ | // below 3
74
+ _ => "4"
75
+ // below 4
76
+ }
63
77
64
78
// Ppat_constraint
65
79
let /* c0 */ number /* c1 */: /* c2 */ int /* c3 */ = 123
Original file line number Diff line number Diff line change @@ -58,6 +58,20 @@ let /* before */ {
58
58
let /* b1 */ Blue /* b2 */ | /* c1 */ Red /* c2 */ = color
59
59
let /* b1 */ Blue /* b2 */ | /* c1 */ Red /* c2 */ | /* d1 */ Green /* d2 */ = color
60
60
61
+ // #462: Comments in nested Ppat_or must not disappear.
62
+ // (comment positions not optimal yet because `|` has no AST location)
63
+ let _ = switch "anything" {
64
+ // above 1
65
+ | "1"
66
+ // below 1
67
+ | "2"
68
+ // below 2
69
+ | "3"
70
+ // below 3
71
+ | _ => "4"
72
+ // below 4
73
+ }
74
+
61
75
// Ppat_constraint
62
76
let /* c0 */ number /* c1 */ : /* c2 */ int /* c3 */ = 123
63
77
You can’t perform that action at this time.
0 commit comments