Commit 9d34f8a7 authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Fix the check that no polymorphic variables occurs in the accepted type of a pattern.

parent 86748961
......@@ -803,7 +803,10 @@ and branches env b =
" It might be a misspelled or undeclared type or name (if it isn't, use _ instead)."));
let fv2 = Fv.diff fv2 fvp in
fv := Fv.cup !fv fv2;
accept := Types.cup !accept (Types.descr (Patterns.accept p));
let p_accept = Types.descr (Patterns.accept p) in
if not (Var.Set.is_empty (Types.all_vars p_accept)) then
error br_loc "Type variables cannot occur in patterns";
accept := Types.cup !accept p_accept;
let ghost = br_loc == noloc in
let br =
......@@ -1261,8 +1264,6 @@ and branches_aux loc env targ tres constr precise = function
| b :: rem ->
let p = b.br_pat in
let acc = Types.descr (Patterns.accept p) in
if not (Var.Set.subset (Types.all_vars acc) then
error b.br_loc "Generalized type variables cannot occur in patterns";
let targ' = Types.cap targ acc in
if Types.is_empty targ' then
(* this branch cannot be selected: we ignore it *)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment