Commit 2b0f24c6 authored by Kim Nguyễn's avatar Kim Nguyễn

Delay the check that detects types variables occurring in patterns until...

Delay the check that detects types variables occurring in patterns until type-checking time (this allows us to have access to delta and thus know the monomorphic variables, which are allowed)
parent 4f8e3799
......@@ -779,10 +779,6 @@ and branches env b =
cur_branch := [];
let ploc = p.loc in
let p = pat env p in
let () =
let t = Types.descr (Patterns.accept p) in
if not (Types.no_var t) then error ploc "Type variables cannot occur in patterns"
in
let fvp = Patterns.fv p in
let (fv2,e) = expr (enter_values_dummy fvp env) noloc e in
let br_loc = merge_loc ploc e.Typed.exp_loc in
......@@ -1264,7 +1260,8 @@ 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) env.delta) 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