diff options
| author | herbelin | 2007-04-13 13:20:51 +0000 |
|---|---|---|
| committer | herbelin | 2007-04-13 13:20:51 +0000 |
| commit | c7b4398341e1fec6c485f39cde8d42fa3ff6abff (patch) | |
| tree | 287f86abf547207168f55c4e4fe37d06f0a58b3d | |
| parent | ba8f9564e492cd8d25a193cfc5883ed06faaea02 (diff) | |
Correction bug #1477 sur ordre des variables partagées par les or-patterns.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@9764 85f007b7-540e-0410-9357-904b9bb8a0f7
| -rw-r--r-- | interp/constrintern.ml | 2 | ||||
| -rw-r--r-- | lib/util.ml | 10 | ||||
| -rw-r--r-- | lib/util.mli | 1 | ||||
| -rw-r--r-- | test-suite/success/Case18.v | 12 |
4 files changed, 22 insertions, 3 deletions
diff --git a/interp/constrintern.ml b/interp/constrintern.ml index f067eda6b5..77e6ba42cf 100644 --- a/interp/constrintern.ml +++ b/interp/constrintern.ml @@ -384,7 +384,7 @@ let check_number_of_pattern loc n l = if n<>p then raise (InternalisationError (loc,BadPatternsNumber (n,p))) let check_or_pat_variables loc ids idsl = - if List.exists ((<>) ids) idsl then + if List.exists (fun ids' -> not (list_eq_set ids ids')) idsl then user_err_loc (loc, "", str "The components of this disjunctive pattern must bind the same variables") diff --git a/lib/util.ml b/lib/util.ml index 66485d5a36..ee373120e2 100644 --- a/lib/util.ml +++ b/lib/util.ml @@ -123,8 +123,6 @@ module Stringmap = Map.Make(struct type t = string let compare = compare end) (* Lists *) -let list_add_set x l = if List.mem x l then l else x::l - let list_intersect l1 l2 = List.filter (fun x -> List.mem x l2) l1 @@ -267,6 +265,14 @@ let rec list_remove_first a = function | b::l -> b::list_remove_first a l | [] -> raise Not_found +let list_add_set x l = if List.mem x l then l else x::l + +let list_eq_set l1 l2 = + let rec aux l1 = function + | [] -> l1 = [] + | a::l2 -> aux (list_remove_first a l1) l2 in + try aux l1 l2 with Not_found -> false + let list_for_all2eq f l1 l2 = try List.for_all2 f l1 l2 with Failure _ -> false let list_map_i f = diff --git a/lib/util.mli b/lib/util.mli index f38f36740c..afa11d31dc 100644 --- a/lib/util.mli +++ b/lib/util.mli @@ -78,6 +78,7 @@ module Stringmap : Map.S with type key = string (*s Lists. *) val list_add_set : 'a -> 'a list -> 'a list +val list_eq_set : 'a list -> 'a list -> bool val list_intersect : 'a list -> 'a list -> 'a list val list_union : 'a list -> 'a list -> 'a list val list_unionq : 'a list -> 'a list -> 'a list diff --git a/test-suite/success/Case18.v b/test-suite/success/Case18.v index 91c80e8891..be9ca8d41b 100644 --- a/test-suite/success/Case18.v +++ b/test-suite/success/Case18.v @@ -12,3 +12,15 @@ Fixpoint max (n m:nat) {struct m} : nat := | S n', S m' => S (max n' m') | 0, p | p, 0 => p end. + +(* Check bug #1477 *) + +Inductive I : Set := + | A : nat -> nat -> I + | B : nat -> nat -> I. + +Definition foo (x:I) : nat := + match x with + | A a b | B b a => S b + end. + |
