@@ -2332,6 +2332,11 @@ module V4 = struct
2332
2332
]
2333
2333
(Exp. ident ~loc: emptyLoc {loc = emptyLoc; txt = Lident txt})
2334
2334
in
2335
+ let stripConstraint pattern =
2336
+ match pattern with
2337
+ | {ppat_desc = Ppat_constraint (pattern , _ )} -> pattern
2338
+ | _ -> pattern
2339
+ in
2335
2340
let rec returnedExpression patternsWithLabel patternsWithNolabel
2336
2341
({pexp_desc} as expr ) =
2337
2342
match pexp_desc with
@@ -2348,14 +2353,19 @@ module V4 = struct
2348
2353
},
2349
2354
expr ) ->
2350
2355
(patternsWithLabel, patternsWithNolabel, expr)
2351
- | Pexp_fun (arg_label , _default , {ppat_loc; ppat_desc} , expr ) -> (
2356
+ | Pexp_fun
2357
+ (arg_label, _default, ({ppat_loc; ppat_desc} as pattern), expr)
2358
+ -> (
2359
+ let pattern = stripConstraint pattern in
2352
2360
if isLabelled arg_label || isOptional arg_label then
2353
2361
returnedExpression
2354
2362
(( {loc = ppat_loc; txt = Lident (getLabel arg_label)},
2355
- Pat. var
2356
- ~attrs:
2363
+ {
2364
+ pattern with
2365
+ ppat_attributes =
2357
2366
(if isOptional arg_label then optionalAttr else [] )
2358
- {txt = getLabel arg_label; loc = ppat_loc} )
2367
+ @ pattern.ppat_attributes;
2368
+ } )
2359
2369
:: patternsWithLabel)
2360
2370
patternsWithNolabel expr
2361
2371
else
@@ -2365,7 +2375,11 @@ module V4 = struct
2365
2375
| Ppat_var {txt} ->
2366
2376
returnedExpression patternsWithLabel
2367
2377
(( {loc = ppat_loc; txt = Lident txt},
2368
- Pat. var ~attrs: optionalAttr {txt; loc = ppat_loc} )
2378
+ {
2379
+ pattern with
2380
+ ppat_attributes =
2381
+ optionalAttr @ pattern.ppat_attributes;
2382
+ } )
2369
2383
:: patternsWithNolabel)
2370
2384
expr
2371
2385
| _ ->
0 commit comments