leanprover / leanprover/lean4

Renaming does not correctly deal with namespaces

Open
#2,936 1 comment 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

#2462 added support for renaming, but the current implementation does not correctly deal with namespaces:

namespace Bar

  structure Foo where
    a : Nat

  def foobar (f : Foo) : Foo := f

end Bar

def foobar (f : Bar.Foo) : Bar.Foo := f

Renaming Foo here breaks references to Bar.Foo. Similarly, when you rename a type, it does not rename the corresponding namespace, leading to errors because dot notation is suddenly broken for a lot of functions.

Context

Prior discussion in the review comments for #2462.

Steps to Reproduce
  1. Use the MWE above.
  2. Rename Foo.
  3. Observe incorrect renaming behaviour.

Expected behavior: Renaming is aware of namespaces.

Actual behavior: Renaming is not aware of namespaces.

Versions

Commit b97b0ad2aaea49a2db3ac0543443ec72bd97dfdc

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 renaming implementation introduced by #2462 and review the discussion in that change. Reproduce the issue using the MWE, then trace how references to Bar.Foo and its corresponding namespace are handled; done means renaming preserves those references and dot notation without errors.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.