Skip to content

fix: look up local declarations in environments built by ofKernelEnv - #14771

Draft
Kha wants to merge 1 commit into
masterfrom
push-wouvwnysyplk
Draft

fix: look up local declarations in environments built by ofKernelEnv#14771
Kha wants to merge 1 commit into
masterfrom
push-wouvwnysyplk

Conversation

@Kha

@Kha Kha commented Aug 13, 2026

Copy link
Copy Markdown
Member

This PR fixes using Environment.find? and its variants on the result of ofKernelEnv.

This also fixes the presentation of at least one kernel error message.

Fixes #13783, more directly

@Kha

Kha commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

!bench

@leanprover-radar

leanprover-radar commented Aug 13, 2026

Copy link
Copy Markdown

Benchmark results for 5ed20d7 against 23393b9 are in. No significant results found. @Kha

  • 🟥 build//instructions: +12.2G (+0.10%)

Small changes (4🟥)

  • 🟥 build/module/Lean.Environment//instructions: +61.8M (+0.41%)
  • 🟥 build/module/Std.Data.DHashMap.Internal.RawLemmas//instructions: +929.9M (+0.37%)
  • 🟥 build/module/Std.Data.DHashMap.RawLemmas//instructions: +368.2M (+0.25%)
  • 🟥 misc/import Std.Data.DHashMap.Internal.RawLemmas//instructions: +884.8M (+0.41%)

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Aug 13, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-08-01 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-13 03:39:01)

@leanprover-bot

leanprover-bot commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

@leanprover-bot leanprover-bot added the breaks-manual This is not necessarily a blocker for merging, but there needs to be a plan. label Aug 13, 2026
This PR makes a kernel error message print declarations of the current module the way they are printed everywhere else, with implicit arguments hidden, where a constant it could not resolve was previously shown fully applied.

`findAsync?` consults the imports and then `asyncConsts`, where an elaborator environment keeps the current module's own declarations. An environment built by `ofKernelEnv` keeps them in the second stage of the kernel environment's constant map instead, which neither lookup reads, so every one of them looked undefined. `findAsyncCore?` and `findTaskCore` now fall back to that stage, which an elaborator environment leaves empty, so nothing else is affected. `enableRealizationsForImports` factors the initialization of `importRealizationCtx?` out of `importModules`, the operation that field's documentation already names, so that such an environment can be given a realization context of its own.

Co-Authored-By: Claude <noreply@anthropic.com>
@Kha
Kha force-pushed the push-wouvwnysyplk branch from 5ed20d7 to 0eea228 Compare August 13, 2026 04:16
@Kha

Kha commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

!bench mathlib

@leanprover-radar

Copy link
Copy Markdown

Waiting until the label mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN is added.

You can edit the original message until the command succeeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaks-manual This is not necessarily a blocker for merging, but there needs to be a plan. toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Environment from Lean.Environment.ofKernelEnv has incorrect find?

3 participants