diff options
| author | Pierre-Marie Pédrot | 2018-12-19 16:26:45 +0100 |
|---|---|---|
| committer | Pierre-Marie Pédrot | 2018-12-19 16:26:45 +0100 |
| commit | c3e9f5f8804c3b1da323cb0a7ba7d1e46ccf0849 (patch) | |
| tree | 46e5f4fe06c02c86bff4550a4d8fd94ef12a406d /vernac | |
| parent | 116f255bb51a8186a1986e5147c09a7129692af9 (diff) | |
| parent | 4e529454022b7d2dc0c57d29c813c5801dfd438c (diff) | |
Merge PR #9231: Fixes #9229: Infix not robust wrt choice of variable names in right-hand side
Diffstat (limited to 'vernac')
| -rw-r--r-- | vernac/metasyntax.ml | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/vernac/metasyntax.ml b/vernac/metasyntax.ml index 4e79b50b79..3da12e7714 100644 --- a/vernac/metasyntax.ml +++ b/vernac/metasyntax.ml @@ -1563,14 +1563,17 @@ let add_notation_extra_printing_rule df k v = (* Infix notations *) -let inject_var x = CAst.make @@ CRef (qualid_of_ident (Id.of_string x),None) +let inject_var x = CAst.make @@ CRef (qualid_of_ident x,None) let add_infix local env ({CAst.loc;v=inf},modifiers) pr sc = check_infix_modifiers modifiers; (* check the precedence *) - let metas = [inject_var "x"; inject_var "y"] in + let vars = names_of_constr_expr pr in + let x = Namegen.next_ident_away (Id.of_string "x") vars in + let y = Namegen.next_ident_away (Id.of_string "y") vars in + let metas = [inject_var x; inject_var y] in let c = mkAppC (pr,metas) in - let df = CAst.make ?loc @@ "x "^(quote_notation_token inf)^" y" in + let df = CAst.make ?loc @@ Id.to_string x ^" "^(quote_notation_token inf)^" "^Id.to_string y in add_notation local env c (df,modifiers) sc (**********************************************************************) |
