Zulip Chat Archive

Stream: lean4

Topic: identifiers don't round-trip through pretty-printing


Eric Wieser (Jul 08 2024 at 13:09):

Is there any way to guard against this?

variable («forall» : Nat)

#check «forall» + 1 -- forall + 1 : Nat

-- paste what we got from the goal view
#check forall + 1 -- syntax error

Eric Wieser (Jul 08 2024 at 13:14):

This looks like a rare case where even pp.all true isn't enough to make things roundtrip

Damiano Testa (Jul 08 2024 at 13:16):

The pretty-printer seems to do the right thing if the identifier contains a space, though.

Eric Wieser (Jul 08 2024 at 13:17):

Yes, I think it knows about invalid identifiers, but not about ones that clash with syntax

Eric Wieser (Jul 08 2024 at 13:17):

I guess a pp.alwaysEscapeNames would be an ugly fix here

Damiano Testa (Jul 08 2024 at 13:19):

That is what happens with new projects in the lakefile, right?

Eric Wieser (Jul 08 2024 at 13:19):

Oh that's a fun test, is lake new forall broken? (answer: no, it escapes any name you use)

Damiano Testa (Jul 08 2024 at 13:20):

I do not know, but I know that I saw a lot of (unneeded) « when I created new projects.

Eric Wieser (Jul 08 2024 at 13:20):

Yes, I think this is probably why

Kyle Miller (Jul 08 2024 at 13:29):

Could you please create an issue? The syntax formatter just uses docs#Lean.Name.toString to print identifiers, and it's not aware of the current list of keywords yet.

Eric Wieser (Jul 08 2024 at 14:05):

lean4#4686


Last updated: May 02 2025 at 03:31 UTC