aboutsummaryrefslogtreecommitdiffhomepage
path: root/interp
diff options
context:
space:
mode:
authorGravatar Paul Steckler <steck@stecksoft.com>2017-06-09 12:30:42 -0400
committerGravatar Paul Steckler <steck@stecksoft.com>2017-06-09 12:30:42 -0400
commit849bf3600fe11fea876c9aeea69fe806b0c8c5d8 (patch)
tree6af03f32f864882392abe7dded939bed439a368f /interp
parent03fee03c9bc31225d8f0c3a1cef206145490d341 (diff)
Fix Bug #5568, no dup notation warnings on repeated module imports
Diffstat (limited to 'interp')
-rw-r--r--interp/notation.ml3
-rw-r--r--interp/notation.mli2
-rw-r--r--interp/notation_ops.ml9
3 files changed, 11 insertions, 3 deletions
diff --git a/interp/notation.ml b/interp/notation.ml
index 389a1c9df..ba80cf1d2 100644
--- a/interp/notation.ml
+++ b/interp/notation.ml
@@ -561,11 +561,12 @@ let interpretation_eq (vars1, t1) (vars2, t2) =
List.equal var_attributes_eq vars1 vars2 &&
Notation_ops.eq_notation_constr (List.map fst vars1, List.map fst vars2) t1 t2
-let exists_notation_in_scope scopt ntn r =
+let exists_notation_in_scope scopt ntn onlyprint r =
let scope = match scopt with Some s -> s | None -> default_scope in
try
let sc = String.Map.find scope !scope_map in
let n = String.Map.find ntn sc.notations in
+ onlyprint = n.not_onlyprinting &&
interpretation_eq n.not_interp r
with Not_found -> false
diff --git a/interp/notation.mli b/interp/notation.mli
index 2e92a00a8..303fa8c7a 100644
--- a/interp/notation.mli
+++ b/interp/notation.mli
@@ -142,7 +142,7 @@ val interp_notation_as_global_reference : Loc.t -> (global_reference -> bool) ->
(** Checks for already existing notations *)
val exists_notation_in_scope : scope_name option -> notation ->
- interpretation -> bool
+ bool -> interpretation -> bool
(** Declares and looks for scopes associated to arguments of a global ref *)
val declare_arguments_scope :
diff --git a/interp/notation_ops.ml b/interp/notation_ops.ml
index 564882153..26e61d13a 100644
--- a/interp/notation_ops.ml
+++ b/interp/notation_ops.ml
@@ -47,9 +47,16 @@ let compare_glob_constr f add t1 t2 = match t1,t2 with
| GHole _ | GSort _ | GLetIn _), _
-> false
+(* helper for NVar, NVar case in eq_notation_constr *)
+let get_var_ndx id vs = try Some (List.index Id.equal id vs) with Not_found -> None
+
let rec eq_notation_constr (vars1,vars2 as vars) t1 t2 = match t1, t2 with
| NRef gr1, NRef gr2 -> eq_gr gr1 gr2
-| NVar id1, NVar id2 -> Int.equal (List.index Id.equal id1 vars1) (List.index Id.equal id2 vars2)
+| NVar id1, NVar id2 -> (
+ match (get_var_ndx id1 vars1,get_var_ndx id2 vars2) with
+ | Some n,Some m -> Int.equal n m
+ | None ,None -> Id.equal id1 id2
+ | _ -> false)
| NApp (t1, a1), NApp (t2, a2) ->
(eq_notation_constr vars) t1 t2 && List.equal (eq_notation_constr vars) a1 a2
| NHole (_, _, _), NHole (_, _, _) -> true (** FIXME? *)