lean4-htt/tests/lean/run/6706.lean
jrr6 e337129108
fix: move auxDeclToFullName to LocalContext to fix name (un)resolution (#7075)
This PR ensures that names suggested by tactics like `simp?` are not
shadowed by auxiliary declarations in the local context and that names
of `let rec` and `where` declarations are correctly resolved in tactic
blocks.

This PR contains the following potentially breaking changes:
* Moves the `auxDeclToFullName` map from `TermElab.Context` to
`LocalContext`.
* Refactors `Lean.Elab.Term.resolveLocalName : Name → TermElabM …` to
`Lean.resolveLocalName [MonadResolveName m] [MonadEnv m] [MonadLCtx m] :
Name → m …`.
* Refactors the `TermElabM` action `Lean.Elab.Term.withAuxDecl` to a
monad-polymorphic action `Lean.Meta.withAuxDecl`.
* Adds an optional `filter` argument to `Lean.unresolveNameGlobal`.

Closes #6706, closes #7073.
2025-03-03 16:10:54 +00:00

22 lines
521 B
Text

/-!
# `simp?`-suggested names conflicting with auxiliary declarations
https://github.com/leanprover/lean4/issues/6706
This test ensures that "unresolved" names provided by `simp?` do not conflict with local auxiliary
declarations.
-/
def P := True
theorem N.A.B : P := trivial
/-- info: Try this: simp only [N.A.B] -/
#guard_msgs in
theorem N.X.A.B : P := by
simp? [N.A.B]
/-- info: Try this: simp only [_root_.N.A.B] -/
#guard_msgs in
theorem A : P :=
let rec N.A.B := ()
by simp? [_root_.N.A.B]
where B := ()