`lean --deps` panics in `HeaderSyntax.imports` on a header that does not parse
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 62/100
Direzione di ricerca
Start with Lean.Elab.parseImports, which passes the result of Parser.parseHeader to headerToImports without checking its messages, then with HeaderSyntax.imports in Lean/Elab/Import.lean, where the unreachable! at line 40 is hit. Reproduce with printf 'import\n' > W.lean && lean --deps W.lean. Done when the header's parse error is reported with a non-zero exit and no panic, for import, import Init., import 3, a tab before import, and a lone carriage return.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
lean --deps panics on any file whose header doesn't parse, then goes on to look up a module named [anonymous]. lean on the same file reports the parse error as a normal message.
Steps to Reproduce
printf 'import\n' > W.lean
lean --deps W.lean
Expected behavior: the header's parse error, as lean W.lean reports it (W.lean:2:0: error: unexpected end of input; expected identifier), with a non-zero exit and no panic.
Actual behavior:
PANIC at Lean.Elab.HeaderSyntax.imports Lean.Elab.Import:40:13: unreachable code has been reached
backtrace:
…
<toolchain>/lib/lean/Init.olean
<toolchain>/lib/lean/Init.olean
unknown module prefix '[anonymous]'
No directory '[anonymous]' or file '[anonymous].olean' in the search path entries:
<toolchain>/lib/lean
The same happens for every header error I tried: import Init., import 3, a tab before an import ("tabs are not allowed"), and an isolated carriage return.
Cause
Lean.Elab.parseImports passes the header that Parser.parseHeader returns to headerToImports without checking the returned messages for errors. On the error-recovered syntax, neither pattern in HeaderSyntax.imports matches, so it reaches unreachable!. printImports (--deps) and printImportSrcs (--src-deps) both go through it. So does any program that calls parseImports to read a header's imports and its end position.
Versions
Lean (version 4.34.1, aarch64-unknown-linux-gnu, commit 5045d0056413266e57c625dcd7c365b10e377c52, Release), on Linux.
Impact
A tool that reads a module's imports with parseImports or lean --deps, as a build driver does before passing them through --setup, has to check the header's messages itself first.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 19h 8m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16305 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16299 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16257 ·
I maintainer di solito rispondono entro 1 giorno
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
leanprover/lean4#15683 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
uselagoon/lagoon-cli#501 · 1 reazione ·
-
area: cli
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
vitruv-tools/NeoJoin#415 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno