fix: mark delta-derived instances as meta when type is meta#13315
Open
kim-em wants to merge 3 commits intoleanprover:masterfrom
Open
fix: mark delta-derived instances as meta when type is meta#13315kim-em wants to merge 3 commits intoleanprover:masterfrom
kim-em wants to merge 3 commits intoleanprover:masterfrom
Conversation
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>
daf1256 to
1d8b608
Compare
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>
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
Kha
reviewed
Apr 8, 2026
| if isPrivateName declName then | ||
| instName := mkPrivateName env instName | ||
| let isMeta := (← read).declName?.any (isMarkedMeta (← getEnv)) | ||
| let isMeta := (← read).isMetaSection || isMarkedMeta (← getEnv) declName |
Member
There was a problem hiding this comment.
This change doesn't seem to match the PR title or be motivated in the test
Kha
reviewed
Apr 8, 2026
Comment on lines
+261
to
+262
| if isMeta then | ||
| modifyEnv (markMeta · instName) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes
processDefDerivingto propagate themetaattribute toinstances derived via delta deriving. Previously,
deriving BEqinside apublic meta sectionfor a definition would produce a non-meta instance,causing the LCNF visibility checker to reject meta definitions that use
==.The fix has two parts:
isMetafrom the meta section scope and the type's meta status,and use it for both
wrapInstanceaux declarations and the main instance.addAndCompile (markMeta := isMeta)(from feat: addmarkMetaparameter toaddAndCompile#13311) so the meta tagis set before compilation, matching how the normal command elaboration
pipeline handles meta definitions.
Audited all other deriving handlers:
Handler-based deriving (BEq, Repr, Hashable, etc. for inductives) all use
elabCommandwithin thewithScope isMetacontext, so they alreadycorrectly produce meta instances.
SizeOf auto-generated instances use
addDeclwith.abbrevhints (notcompiled), so they need separate handling — deferred for now.
depends on: feat: add
markMetaparameter toaddAndCompile#13311Closes #13313
🤖 Prepared with Claude Code