Skip to content

Commit f227150

Browse files
committed
Fix untypeast handling of pvb_constraint
oops
1 parent 3d20281 commit f227150

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

testsuite/tests/compiler-libs/test_untypeast.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ run {| fun x y z -> (function w -> x y z w) |};;
6767
run {| let foo : 'a. 'a -> 'a = fun x -> x in foo |}
6868

6969
[%%expect{|
70-
- : string = "let (foo : ('a : value) . 'a -> 'a) = fun x -> x in foo"
70+
- : string = "let foo : ('a : value) . 'a -> 'a = fun x -> x in foo"
7171
|}];;
7272

7373
run {| let foo : type a . a -> a = fun x -> x in foo |}
7474

7575
[%%expect{|
7676
- : string =
77-
"let (foo : ('a : value) . 'a -> 'a) =\n fun (type a) -> ( (fun x -> x : a -> a)) in\nfoo"
77+
"let foo : ('a : value) . 'a -> 'a = fun (type a) -> ( (fun x -> x : a -> a)) in\nfoo"
7878
|}];;
7979

8080
(* CR: untypeast/pprintast are totally busted on programs with modes in value
@@ -89,5 +89,5 @@ Exception: Misc.Fatal_error.
8989
run {| let foo : 'a . 'a -> 'a @@ portable = fun x -> x in foo |}
9090

9191
[%%expect{|
92-
- : string = "let (foo : ('a : value) . 'a -> 'a) = fun x -> x in foo"
92+
- : string = "let foo : ('a : value) . 'a -> 'a = fun x -> x in foo"
9393
|}];;

typing/untypeast.ml

+10-3
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,16 @@ let case : type k . mapper -> k case -> _ = fun sub {c_lhs; c_guard; c_rhs} ->
437437
let value_binding sub vb =
438438
let loc = sub.location sub vb.vb_loc in
439439
let attrs = sub.attributes sub vb.vb_attributes in
440-
Vb.mk ~loc ~attrs
441-
(sub.pat sub vb.vb_pat)
442-
(sub.expr sub vb.vb_expr)
440+
let pat = sub.pat sub vb.vb_pat in
441+
let pat, value_constraint, modes =
442+
match pat.ppat_desc with
443+
| Ppat_constraint (pat, Some ({ ptyp_desc = Ptyp_poly _; _ } as cty),
444+
modes) ->
445+
let constr = Pvc_constraint {locally_abstract_univars = []; typ = cty } in
446+
pat, Some constr, modes
447+
| _ -> pat, None, []
448+
in
449+
Vb.mk ~loc ~attrs ?value_constraint ~modes pat (sub.expr sub vb.vb_expr)
443450

444451
let comprehension sub comp =
445452
let iterator = function

0 commit comments

Comments
 (0)