diff --git a/testsuite/tests/match-exception-warnings/pressure_variants.ml b/testsuite/tests/match-exception-warnings/pressure_variants.ml new file mode 100644 index 000000000..329152d80 --- /dev/null +++ b/testsuite/tests/match-exception-warnings/pressure_variants.ml @@ -0,0 +1,31 @@ +(* Regression testing for PR#7083 *) +let simple x = + match x with + | `A -> () + | exception Not_found -> () +;; + +let moderatly_less_simple x = + match x with + | `A | exception Exit -> () +;; + +let less_simple x = + match x with + | `A | exception Exit -> () + | exception Not_found -> () +;; + +type t = [ `A | `B ] + +let plain_weird x = + match x with + | #t -> () + | exception Not_found -> () +;; + +let plain_weird' x = + match x with + | #t | exception Exit -> () + | exception Not_found -> () +;; diff --git a/testsuite/tests/match-exception-warnings/pressure_variants.ml.reference b/testsuite/tests/match-exception-warnings/pressure_variants.ml.reference new file mode 100644 index 000000000..16ca169c8 --- /dev/null +++ b/testsuite/tests/match-exception-warnings/pressure_variants.ml.reference @@ -0,0 +1,8 @@ + +# val simple : [< `A ] -> unit = +# val moderatly_less_simple : [< `A ] -> unit = +# val less_simple : [< `A ] -> unit = +# type t = [ `A | `B ] +val plain_weird : [< t ] -> unit = +# val plain_weird' : [< t ] -> unit = +# diff --git a/typing/parmatch.ml b/typing/parmatch.ml index 0983ae3f0..25cd1a8e2 100644 --- a/typing/parmatch.ml +++ b/typing/parmatch.ml @@ -533,7 +533,7 @@ let filter_all pat0 pss = filter_rec env ((p::ps)::pss) | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> filter_rec env ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))}::_)::pss -> + | ({pat_desc = (Tpat_any | Tpat_var(_) | Tpat_exception(_))}::_)::pss -> filter_rec env pss | (p::ps)::pss -> filter_rec (insert p ps env) pss