Zulip Chat Archive

Stream: general

Topic: build cycle detected


Kevin Buzzard (Aug 04 2023 at 21:12):

Turns out that

stderr:
error: build cycle detected:
  +Game.Levels.Tutorial:lean.precompileImports
  +Game.Levels.Tutorial:lean.precompileImports

actually means "you can't import a file whose name starts with a numeral". This came about because I was changing a bunch of names of files from Level_01.lean, Level_02.lean.. into names like add_comm.lean and add_assoc.lean, and a passing computer scientist said "add the numbers at the front so they'll be sorted correctly in VS Code". I'm now going for L04add_comm.lean.

Scott Morrison (Aug 05 2023 at 03:42):

Mathematics in Lean uses the same solution.

Eric Wieser (Aug 05 2023 at 20:59):

Does import «01-add_comm» not work?

Kevin Buzzard (Aug 05 2023 at 23:38):

Do I need to put the package name in front of that?

Scott Morrison (Aug 05 2023 at 23:39):

I would strongly prefer we avoid french quotes in import statements, even to the point of proposing to disallow them. Whatever gain you think you're getting locally is outweighed by the suffering of the ecosystem having to cope with weird names.

Jon Eugster (Aug 06 2023 at 08:28):

something like L02_AddComm.lean sounds like the right thing to do

Mac Malone (Aug 07 2023 at 23:05):

Kevin Buzzard said:

"you can't import a file whose name starts with a numeral"

That sounds like a bug in import parsing, it should give a much cleaner error than that.

Mac Malone (Aug 07 2023 at 23:12):

Scott Morrison said:

Whatever gain you think you're getting locally is outweighed by the suffering of the ecosystem having to cope with weird names.

While I agree in spirit, we already permit a number of complexities in the import header -- line comments and nested block comments (in arbitrary locations), unicode, and special import keywords (e.g., prelude, runtime) -- that the parser is not trivial anyway. Thus, accounting for french quotes likely adds little complexity.

Scott Morrison (Aug 07 2023 at 23:15):

Ugh, but it's needless complexity, verging on complexity for its own sake. Life is better if french quotes are not allowed in imports.

Mario Carneiro (Aug 07 2023 at 23:16):

the complexity isn't needless, this came up in mathport in fact

Mario Carneiro (Aug 07 2023 at 23:17):

also consider that files may be written by tools, not humans, and there may be reasons to use weird characters and/or handle whatever the user provides

Scott Morrison (Aug 07 2023 at 23:17):

But the correct fix is to rename your files, as they did in MIL. (Note some of the MIL authors above agreeing with this. :-)

Mac Malone (Aug 07 2023 at 23:17):

Lake also uses French quotes imports for generating projects, but it could instead follow whatever rules exist.

Mario Carneiro (Aug 07 2023 at 23:18):

I think that having french-quote-free names is a fine project naming convention, but it doesn't belong in lake

Mac Malone (Aug 07 2023 at 23:21):

The interesting thing about the Lake use case is it does demonstrate that the lack of French quotes would increase the complexity of project generation code, rather than decrease it. This connects to @Mario Carneiro's point that tools generate Lean code may like it even if tools consuming Lean code do not. So, there is question of where does the burden belong.

Mac Malone (Aug 07 2023 at 23:22):

Given the already existing complexity of the import header parser, I would be inclined to put the burden there.

Mac Malone (Aug 07 2023 at 23:33):

Mac Malone said:

That sounds like a bug in import parsing, it should give a much cleaner error than that.

Looking at the parse code the problem is that encountering import A.0X is parsed as import A and then the .0X as the beginning of the code block. This is fine within the Lean code as it will still produce an error, but for the parse import in Lake, this hides the error (as Lake does not parse the rest of the file until is built) and produces a build loop on A. I will take a look at potentially solving this within the import parser code.


Last updated: Dec 20 2023 at 11:08 UTC