Skip to content

fix(generate): skip leading copyright block in import prelude - #467

Merged
kim-em merged 4 commits into
leanprover:mainfrom
BoltonBailey:fix/generate-copyright-prelude
Jul 29, 2026
Merged

fix(generate): skip leading copyright block in import prelude#467
kim-em merged 4 commits into
leanprover:mainfrom
BoltonBailey:fix/generate-copyright-prelude

Conversation

@BoltonBailey

@BoltonBailey BoltonBailey commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Disclaimer: Claude identified this as an issue as I was asking it to assemble another PR, which included files with both copyright headers and definitional dependencies to the main theorem. I asked Claude to write and PR this fix - it wrote it itself but I have checked it over and it looks OK to me.

My summary is that importPreludeLength previously has not accounted for the possible presence of a copyright header, and isn't getting any prelude for files that have such a header. This turns out not to cause problems for files that don't rely on defs, but it seems it does for files that do.

`importPreludeLength` only consumed leading `import` and blank lines, so
for source files using Mathlib's copyright-then-import layout it returned
0. `renderChallengeDepsCore` then sliced the body from offset 0 and — on
the kept-declarations path, which (unlike the local-imports path) never
calls `stripProblemMarkers` — copied the copyright block and
`import EvalTools.Markers` into the generated `ChallengeDeps.lean`. The
standalone (Mathlib-only) workspace then failed to build with
`unknown module prefix 'EvalTools'`.

Skip a leading block comment that precedes the first `import` line
(nesting-aware), so the copyright header is treated as part of the
prelude. Comments after an import are left untouched, so the existing
import-first files generate identically (verified: `generate --check`
reports no changes on the committed problems; regenerating a copyright-
first problem now produces a clean `ChallengeDeps.lean`).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BoltonBailey
BoltonBailey marked this pull request as ready for review June 25, 2026 00:39
@BoltonBailey
BoltonBailey marked this pull request as draft June 25, 2026 01:01
@BoltonBailey
BoltonBailey marked this pull request as ready for review June 28, 2026 00:37
@kim-em
kim-em merged commit 90175b9 into leanprover:main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants