Skip to content

feat: add markMeta parameter to addAndCompile#13311

Merged
Kha merged 2 commits intoleanprover:masterfrom
kim-em:kim/addAndCompile-markMeta
Apr 8, 2026
Merged

feat: add markMeta parameter to addAndCompile#13311
Kha merged 2 commits intoleanprover:masterfrom
kim-em:kim/addAndCompile-markMeta

Conversation

@kim-em
Copy link
Copy Markdown
Collaborator

@kim-em kim-em commented Apr 8, 2026

This PR adds an optional markMeta : Bool := false parameter to addAndCompile, so that callers can propagate the meta marking without manually splitting into addDecl + markMeta + compileDecl.

Also updates ParserCompiler to use the new parameter.

🤖 Prepared with Claude Code

kim-em and others added 2 commits April 8, 2026 11:04
Downstream projects that dynamically create definitions derived from
`meta` declarations need to split `addAndCompile` into `addDecl` +
`markMeta` + `compileDecl` to propagate the meta marking before
compilation. Adding an optional `markMeta` flag avoids this boilerplate.

Also updates `ParserCompiler` to use the new parameter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The import is only used in the body of `addAndCompile`, not in its
public signature.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kim-em kim-em requested a review from Kha April 8, 2026 01:18
@kim-em kim-em added the changelog-language Language features and metaprograms label Apr 8, 2026
@kim-em
Copy link
Copy Markdown
Collaborator Author

kim-em commented Apr 8, 2026

We have 4 repeats of this pattern in Verso moving to v4.30.0-rc1.

leanprover/verso#823

kim-em added a commit to kim-em/lean4 that referenced this pull request Apr 8, 2026
This PR fixes `processDefDeriving` to propagate the `meta` attribute to
instances derived via delta deriving. Previously, `deriving BEq` inside a
`public meta section` for a definition would produce a non-meta instance,
causing the LCNF visibility checker to reject meta definitions that use `==`.

The fix has two parts:
1. Compute `isMeta` from the meta section scope and the type's meta status,
   and use it for both `wrapInstance` aux declarations and `addAndCompile`.
2. Use `addAndCompile (markMeta := isMeta)` (from leanprover#13311) so the meta tag
   is set before compilation, matching how the normal command elaboration
   pipeline handles meta definitions.

Closes leanprover#13313

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kim-em added a commit to kim-em/lean4 that referenced this pull request Apr 8, 2026
This PR fixes `processDefDeriving` to propagate the `meta` attribute to
instances derived via delta deriving. Previously, `deriving BEq` inside a
`public meta section` for a definition would produce a non-meta instance,
causing the LCNF visibility checker to reject meta definitions that use `==`.

The fix has two parts:
1. Compute `isMeta` from the meta section scope and the type's meta status,
   and use it for both `wrapInstance` aux declarations and `addAndCompile`.
2. Use `addAndCompile (markMeta := isMeta)` (from leanprover#13311) so the meta tag
   is set before compilation, matching how the normal command elaboration
   pipeline handles meta definitions.

Closes leanprover#13313

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kim-em added a commit to kim-em/lean4 that referenced this pull request Apr 8, 2026
This PR fixes `processDefDeriving` to propagate the `meta` attribute to
instances derived via delta deriving. Previously, `deriving BEq` inside a
`public meta section` for a definition would produce a non-meta instance,
causing the LCNF visibility checker to reject meta definitions that use `==`.

The fix has two parts:
1. Compute `isMeta` from the meta section scope and the type's meta status,
   and use it for both `wrapInstance` aux declarations and `addAndCompile`.
2. Use `addAndCompile (markMeta := isMeta)` (from leanprover#13311) so the meta tag
   is set before compilation, matching how the normal command elaboration
   pipeline handles meta definitions.

Closes leanprover#13313

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kim-em added a commit to kim-em/lean4 that referenced this pull request Apr 8, 2026
This PR fixes `processDefDeriving` to propagate the `meta` attribute to
instances derived via delta deriving. Previously, `deriving BEq` inside a
`public meta section` for a definition would produce a non-meta instance,
causing the LCNF visibility checker to reject meta definitions that use `==`.

The fix has two parts:
1. Compute `isMeta` from the meta section scope and the type's meta status,
   and use it for both `wrapInstance` aux declarations and `addAndCompile`.
2. Use `addAndCompile (markMeta := isMeta)` (from leanprover#13311) so the meta tag
   is set before compilation, matching how the normal command elaboration
   pipeline handles meta definitions.

Closes leanprover#13313

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Kha Kha added this pull request to the merge queue Apr 8, 2026
Merged via the queue into leanprover:master with commit 334d9bd Apr 8, 2026
28 of 29 checks passed
github-actions bot pushed a commit that referenced this pull request Apr 8, 2026
This PR adds an optional `markMeta : Bool := false` parameter to
`addAndCompile`, so that callers can propagate the `meta` marking
without manually splitting into `addDecl` + `markMeta` + `compileDecl`.

Also updates `ParserCompiler` to use the new parameter.

🤖 Prepared with Claude Code

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
(cherry picked from commit 334d9bd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport releases/v4.30.0 changelog-language Language features and metaprograms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants