leanprover / leanprover/lean4

`local elab` cannot use privately imported meta defs

Open
#13,329 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

A local elab command cannot use privately imported meta definitions, in contrast to local elab_rules and local macro.

A.lean:

module
public import Lean

public meta def myZeroExpr : Lean.Expr := Lean.mkNatLit 0

B.lean:

module
public import Lean
import MyNightlyTesting.A -- NO `public`

/- Invalid public `meta` definition
`_aux_MyNightlyTesting_B___elabRules__private_MyNightlyTesting_B_0_termMyZero_1`,
`myZeroExpr` is not accessible here; consider adding `public import MyNightlyTesting.A` -/
local elab "myZero" : term => pure myZeroExpr
Context

This issue prevents modulizing Mathlib tests in leanprover-community/mathlib4#34466.

Versions

Lean 4.31.0-nightly-2026-04-08
Ubuntu 24.04.4

Additional Information

The fix for this issue is easy, I will create the PR soon.

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal reproduction in A.lean and B.lean, focusing on the local elab command, private import, and meta definition. Run the example against the specified Lean nightly and confirm that local elab can use the privately imported meta definition without the invalid-public error.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.