RFC: `lake shake` over the roots of two or more executables in one call

Aperta
#16,498 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Ambito
tooling

Direzione di ricerca

Read Lake/CLI/Shake.lean for lake shake root handling and Lean/Environment.lean around ImportState.markAllExported; the proposal identifies both as change locations. The linked branch includes a test, so inspect it for the expected behavior and run the relevant Lake shake tests. Done means multiple executable roots are handled together, including grouped imports, with suggestions or --fix applied only after every group succeeds.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

P-medium
Proposal

lake shake refuses the roots of two or more executables in one call: each declares main, and loading them into one environment fails in finalizeImport:

error: import B failed, environment already contains 'main' from A

A project with two or more executables runs one lake shake per root, each loading its whole import closure again. Each call sees only the modules under its own roots, and on a project of ours, applying the suggestions of separate calls for two of its modules alone left five others unbuildable.

The proposal is to accept such roots in one call:

  • Before finalizeImport, every main past the first, with the declarations its own module names under it, gets a name of its own, <module>._shake_main, in its module and the modules importing it.
  • When the roots' modules don't load together, each root joins the first group whose modules, with its own, do, the groups checked within one process, each analysing the modules under all of the call's roots, so an edit in one group reaches the modules of a later group.
  • With two groups or more, suggestions are printed, and --fix writes files, only once every group has succeeded; --add-downstream is refused when the roots are split into groups.

User experience: one call checks all of a project's executables together, and when a module's re-export is removed, its dependents in other executables are told to import what they use.

Beneficiaries: projects with two or more executables. On a project of ours (not public) of 120 modules and 45 executables, one patched call over every module took 5.36 s of wall time, against 15.99 s for one unpatched call per module, 25 at a time.

Maintainability: the change adds to Lean/Environment.lean a structure and five functions on ImportState, documented as intended for shake only, beside ImportState.markAllExported, and the grouping to Lake/CLI/Shake.lean. A branch with the change and a test is ready. It was compiled and tested on the Lean nightly nightly-2026-11-16, whose Environment.lean and Shake.lean are those of the commit it is based on, and measured on v4.36.0-rc2.

Community Feedback

An issue search for shake found none about two or more executables in one call.

Lingua principale
Lean
Stelle
10.3k
Fork
1.1k
Merge medio
19h 8m
PR unite (30g)
421

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di leanprover/lean4

Tutte le issue di leanprover/lean4

Issue simili

Altre issue su DevTools

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.