limit propagation of type constraints to patterns to -principal mode

git-svn-id: http://caml.inria.fr/svn/ocaml/branches/gadts@11012 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Jacques Garrigue 2011-04-19 02:34:54 +00:00
parent ea15141d8a
commit 3e7936cc2c
1 changed files with 4 additions and 2 deletions

View File

@ -2506,9 +2506,11 @@ and type_let env rec_flag spat_sexp_list scope allow =
List.map
(fun (spat, sexp) ->
match spat.ppat_desc, sexp.pexp_desc with
Ppat_constraint _, _ -> spat
(Ppat_any | Ppat_constraint _), _ -> spat
| _, Pexp_constraint (_, _, Some sty)
| _, Pexp_constraint (_, Some sty, None) ->
| _, Pexp_constraint (_, Some sty, None) when !Clflags.principal ->
(* propagate type annotation to pattern,
to allow it to be generalized in -principal mode *)
{ppat_desc = Ppat_constraint
(spat, {ptyp_desc=Ptyp_poly([],sty);
ptyp_loc={sty.ptyp_loc with Location.loc_ghost=true}});