File tree 3 files changed +31
-3
lines changed
testsuite/tests/compiler-libs
3 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -457,6 +457,10 @@ Working version
457
457
the right-hand side of `_ as _`.
458
458
(Samuel Vivien, review by Gabriel Scherer)
459
459
460
+ - #13845: Fix bug in untypeast/pprintast for value bindings with polymorphic
461
+ type annotations.
462
+ (Chris Casinghino, review by Florian Angeletti and Gabriel Scherer)
463
+
460
464
OCaml 5.3.0 (8 January 2025)
461
465
----------------------------
462
466
Original file line number Diff line number Diff line change @@ -37,3 +37,19 @@ run {| fun x y z -> (function w -> x y z w) |};;
37
37
[%% expect{|
38
38
- : string = " fun x y z -> (function | w -> x y z w)"
39
39
| }];;
40
+
41
+ (* **********************************)
42
+ (* Untypeast/pprintast correctly handle value binding type annotations. *)
43
+
44
+ run {| let foo : 'a. 'a -> 'a = fun x -> x in foo | }
45
+
46
+ [%% expect{|
47
+ - : string = " let foo : 'a . 'a -> 'a = fun x -> x in foo"
48
+ | }];;
49
+
50
+ run {| let foo : type a . a -> a = fun x -> x in foo | }
51
+
52
+ [%% expect{|
53
+ - : string =
54
+ " let foo : 'a . 'a -> 'a = fun (type a) -> (fun x -> x : a -> a) in foo"
55
+ | }]
Original file line number Diff line number Diff line change @@ -387,9 +387,17 @@ let case : type k . mapper -> k case -> _ = fun sub {c_lhs; c_guard; c_rhs} ->
387
387
let value_binding sub vb =
388
388
let loc = sub.location sub vb.vb_loc in
389
389
let attrs = sub.attributes sub vb.vb_attributes in
390
- Vb. mk ~loc ~attrs
391
- (sub.pat sub vb.vb_pat)
392
- (sub.expr sub vb.vb_expr)
390
+ let pat = sub.pat sub vb.vb_pat in
391
+ let pat, value_constraint =
392
+ match pat.ppat_desc with
393
+ | Ppat_constraint (pat , ({ ptyp_desc = Ptyp_poly _ ; _ } as cty )) ->
394
+ let constr =
395
+ Pvc_constraint { locally_abstract_univars = [] ; typ = cty }
396
+ in
397
+ pat, Some constr
398
+ | _ -> pat, None
399
+ in
400
+ Vb. mk ~loc ~attrs ?value_constraint pat (sub.expr sub vb.vb_expr)
393
401
394
402
let expression sub exp =
395
403
let loc = sub.location sub exp.exp_loc in
You can’t perform that action at this time.
0 commit comments