aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Herbelin2016-10-03 22:12:56 +0200
committerHugo Herbelin2016-10-03 22:13:55 +0200
commit14f8db195021e709734ed89d9cb513d1c0db6a93 (patch)
tree6ec88d1caaeab4ea5453b63234e466a475b67b88
parent89ec88f1e750cfb786de1929ef44fac70c9a29ab (diff)
Fixing #4970 (confusion between special "{" and non special "{{" in notations).
-rw-r--r--test-suite/bugs/closed/4970.v3
-rw-r--r--toplevel/metasyntax.ml5
2 files changed, 7 insertions, 1 deletions
diff --git a/test-suite/bugs/closed/4970.v b/test-suite/bugs/closed/4970.v
new file mode 100644
index 0000000000..7a896582f5
--- /dev/null
+++ b/test-suite/bugs/closed/4970.v
@@ -0,0 +1,3 @@
+(* Check "{{" is not confused with "{" in notations *)
+Reserved Notation "x {{ y }}" (at level 40).
+Notation "x {{ y }}" := (x y) (only parsing).
diff --git a/toplevel/metasyntax.ml b/toplevel/metasyntax.ml
index 92208e3046..4f41043e87 100644
--- a/toplevel/metasyntax.ml
+++ b/toplevel/metasyntax.ml
@@ -1203,7 +1203,10 @@ let contract_notation ntn =
let rec aux ntn i =
if i <= String.length ntn - 5 then
let ntn' =
- if String.is_sub "{ _ }" ntn i then
+ if String.is_sub "{ _ }" ntn i &&
+ (i = 0 || ntn.[i-1] = ' ') &&
+ (i = String.length ntn - 5 || ntn.[i+5] = ' ')
+ then
String.sub ntn 0 i ^ "_" ^
String.sub ntn (i+5) (String.length ntn -i-5)
else ntn in