fix(util/name): escape empty name components using french quotes
This commit is contained in:
parent
092fc89333
commit
2804a0ea27
4 changed files with 10 additions and 2 deletions
|
|
@ -1842,7 +1842,7 @@ std::string sexpr_to_string(sexpr const & s) {
|
|||
// check whether a space must be inserted between the strings so that lexing them would
|
||||
// produce separate tokens
|
||||
std::pair<bool, token_table const *> pretty_fn::needs_space_sep(token_table const * last, std::string const & s1, std::string const & s2) const {
|
||||
if (is_id_rest(get_utf8_last_char(s1.data()), s1.data() + s1.size()) && is_id_rest(s2.data(), s2.data() + s2.size()))
|
||||
if (s1.size() == 0 || (is_id_rest(get_utf8_last_char(s1.data()), s1.data() + s1.size()) && is_id_rest(s2.data(), s2.data() + s2.size())))
|
||||
return mk_pair(true, nullptr); // would be lexed as a single identifier without space
|
||||
|
||||
if (last) {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ void name::imp::display_core(std::ostream & out, imp * p, bool escape, char cons
|
|||
}
|
||||
}
|
||||
}
|
||||
if (must_escape)
|
||||
if (must_escape || sz == 0)
|
||||
out << "«" << p->m_str << "»";
|
||||
else
|
||||
out << p->m_str;
|
||||
|
|
|
|||
4
tests/lean/empty_french_quote.lean
Normal file
4
tests/lean/empty_french_quote.lean
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def «» := not
|
||||
theorem thm : «» false := id
|
||||
#print «»
|
||||
#print thm
|
||||
4
tests/lean/empty_french_quote.lean.expected.out
Normal file
4
tests/lean/empty_french_quote.lean.expected.out
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def «» : Prop → Prop :=
|
||||
not
|
||||
theorem thm : «» false :=
|
||||
id
|
||||
Loading…
Add table
Reference in a new issue