Zulip Chat Archive
Stream: lean4
Topic: Server out of sync with file
Floris van Doorn (Nov 24 2023 at 13:36):
I think people have mentioned that sometimes the Lean server will get out of sync with the state of the file. I just found a way to reproduce it. I can reproduce it on v4.2.0
, but also on other versions on Mathlib. This is on Windows, does this reproduce on other machines?
(1) Download mathlib and its cache
(2) Create a new file with the following contents, and wait until Lean has compiled the file
import Mathlib
#eval 1+1
(3) Delete the first line all at once (e.g. with ctrl+X). On my computer this does not cause a recompilation of the file
(4) Type the letter a
on the first line and wait until Lean shows an error
(5) Remove the letter a
. The error remains. The error remains even if you start typing new commands (e.g. def foo := 1
), and the server is interpreting as a letter a
floating somewhere in your file. It disappears once you write import
again.
I experimented with importing less than Mathlib
, and below a certain number of imports, this behavior seems to go away. (e.g. if we replace import Mathlib
with import Std
, then step 3 does cause a recompilation of the file.
Damiano Testa (Nov 24 2023 at 14:40):
I tried, but I cannot reproduce on Linux with VSCode.
(Also, the online editor does not seem to have the behaviour that you mention.)
Floris van Doorn (Nov 24 2023 at 15:26):
Interesting. Thanks for trying.
Can someone on Windows try to reproduce this?
Sebastien Gouezel (Nov 24 2023 at 15:49):
I'm on windows, and I get the same behavior as the one you describe, with a phantom a
floating around. For instance, if my first line is
theorem foo : True := trivial
I get the error message
unknown identifier 'triviala'
Floris van Doorn (Nov 24 2023 at 15:53):
Kevin Buzzard (Nov 24 2023 at 15:56):
Also on linux, when I delete the first line all at once in step 3 I very briefly see orange bars, and the error does not remain in step 5.
Eric Wieser (Nov 24 2023 at 19:24):
Does this error persist if you save the file with unix line endings?
Floris van Doorn (Nov 24 2023 at 21:09):
Yes, this happens if the file is using unix line endings (VSCode is showing LF
in the bottom-right).
Last updated: Dec 20 2023 at 11:08 UTC