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 +40
-1
lines changed
tests/parsing/grammar/expressions Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -3066,6 +3066,7 @@ and parseExprBlockItem p =
3066
3066
Ast_helper.Exp. open_ ~loc od.popen_override od.popen_lid blockExpr
3067
3067
| Let ->
3068
3068
let recFlag, letBindings = parseLetBindings ~attrs p in
3069
+
3069
3070
parseNewlineOrSemicolonExprBlock p;
3070
3071
let next =
3071
3072
if Grammar. isBlockExprStart p.Parser. token then parseExprBlock p
@@ -3076,7 +3077,35 @@ and parseExprBlockItem p =
3076
3077
None
3077
3078
in
3078
3079
let loc = mkLoc startPos p.prevEndPos in
3079
- Ast_helper.Exp. let_ ~loc recFlag letBindings next
3080
+
3081
+ let res =
3082
+ match letBindings with
3083
+ | [
3084
+ {
3085
+ pvb_pat =
3086
+ {
3087
+ ppat_desc =
3088
+ Ppat_construct
3089
+ ({txt = Lident " Some" }, Some ({ppat_desc = Ppat_var _} as pat));
3090
+ };
3091
+ pvb_expr;
3092
+ };
3093
+ ]
3094
+ when recFlag = Nonrecursive ->
3095
+ let lid_none = Location. mknoloc (Longident. Lident " None" ) in
3096
+ let pat_none = Ast_helper.Pat. construct lid_none None in
3097
+ let exp_none = Ast_helper.Exp. construct lid_none None in
3098
+ let case_none = Ast_helper.Exp. case pat_none exp_none in
3099
+ let lid_some = Location. mknoloc (Longident. Lident " Some" ) in
3100
+ let pat_some = Ast_helper.Pat. construct lid_some (Some pat) in
3101
+ let case_some = Ast_helper.Exp. case pat_some next in
3102
+ let match_exp =
3103
+ Ast_helper.Exp. match_ ~loc pvb_expr [case_none; case_some]
3104
+ in
3105
+ match_exp
3106
+ | _ -> Ast_helper.Exp. let_ ~loc recFlag letBindings next
3107
+ in
3108
+ res
3080
3109
| _ ->
3081
3110
let e1 =
3082
3111
let expr = parseExpr p in
Original file line number Diff line number Diff line change
1
+ let foo = (x , y ) => {
2
+ let Some (vx ) = x
3
+ let Some (vy ) = y
4
+ Some (vx + vy )
5
+ }
Original file line number Diff line number Diff line change
1
+ let foo x y =
2
+ ((match x with
3
+ | None -> None
4
+ | Some vx -> (match y with | None -> None | Some vy -> Some (vx + vy)))
5
+ [@ns.braces ])
You can’t perform that action at this time.
0 commit comments