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

Allow monomorphic type variables in patterns.

parent 239dfe25
......@@ -1065,8 +1065,8 @@ and branches env b =
let fv2 = Fv.diff fv2 fvp in
fv := Fv.cup !fv fv2;
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";
(*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 =
......@@ -1291,6 +1291,15 @@ and type_check' loc env ed constr precise = match ed with
(ed,t)
| Match (e,b) ->
List.iter
(fun br ->
let type_pat =
Types.descr (Patterns.accept br.br_pat)
in
let vars = Types.all_vars type_pat in
if not (Var.Set.subset vars env.delta) then
error br.br_loc "Polymoprhic type variables cannot occur in patterns"
) b.br_branches;
let t = type_check env e b.br_accept true in
let pargs = pat_list_of_expr e in
(ed,type_check_branches loc env t pargs b constr precise)
......
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