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

Commit d022a22

Browse files
committed
Generalize Some case.
1 parent d1a4a12 commit d022a22

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/res_core.ml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,25 +3082,20 @@ and parseExprBlockItem p =
30823082
match letBindings with
30833083
| [
30843084
{
3085-
pvb_pat =
3086-
{
3087-
ppat_desc =
3088-
Ppat_construct
3089-
({txt = Lident "Some"}, Some ({ppat_desc = Ppat_var _} as pat));
3090-
};
3085+
pvb_pat = {ppat_desc = Ppat_construct ({txt = Lident "Some"}, Some pat)};
30913086
pvb_expr;
30923087
};
30933088
]
30943089
when recFlag = Nonrecursive ->
30953090
let lid_none = Location.mknoloc (Longident.Lident "None") in
3096-
let pat_none = Ast_helper.Pat.construct lid_none None in
3091+
let pat_any = Ast_helper.Pat.any () in
30973092
let exp_none = Ast_helper.Exp.construct lid_none None in
3098-
let case_none = Ast_helper.Exp.case pat_none exp_none in
3093+
let case_any = Ast_helper.Exp.case pat_any exp_none in
30993094
let lid_some = Location.mknoloc (Longident.Lident "Some") in
31003095
let pat_some = Ast_helper.Pat.construct lid_some (Some pat) in
31013096
let case_some = Ast_helper.Exp.case pat_some next in
31023097
let match_exp =
3103-
Ast_helper.Exp.match_ ~loc pvb_expr [case_none; case_some]
3098+
Ast_helper.Exp.match_ ~loc pvb_expr [case_some; case_any]
31043099
in
31053100
match_exp
31063101
| _ -> Ast_helper.Exp.let_ ~loc recFlag letBindings next
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
let foo = (x, y) => {
22
let Some(vx) = x
3-
let x1 = vx+1
4-
let Some(vy) = y
5-
let y1 = vy+1
3+
let x1 = vx + 1
4+
let Some({vy, vz: 3}) = y
5+
let y1 = vy + 1
66
Some(x1 + y1)
77
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
let foo x y =
22
((match x with
3-
| None -> None
43
| Some vx ->
54
let x1 = vx + 1 in
65
(match y with
7-
| None -> None
8-
| Some vy -> let y1 = vy + 1 in Some (x1 + y1)))
6+
| Some { vy; vz = 3 } -> let y1 = vy + 1 in Some (x1 + y1)
7+
| _ -> None)
8+
| _ -> None)
99
[@ns.braces ])

0 commit comments

Comments
 (0)