Skip to content

[Merged by Bors] - feat(Tactic/ToFun): warn if provided name matches autogenerated one#39598

Closed
grunweg wants to merge 5 commits into
leanprover-community:masterfrom
grunweg:tofun-warn-redundant-name
Closed

[Merged by Bors] - feat(Tactic/ToFun): warn if provided name matches autogenerated one#39598
grunweg wants to merge 5 commits into
leanprover-community:masterfrom
grunweg:tofun-warn-redundant-name

Conversation

@grunweg

@grunweg grunweg commented May 19, 2026

Copy link
Copy Markdown
Contributor

This PR advises the user to remove a name they explicitly provided to @[to_fun] if it matches the name @[to_fun] would autogenerate.


Open in Gitpod

@grunweg grunweg added WIP Work in progress t-meta Tactics, attributes or user commands awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. easy < 20s of review time. See the lifecycle page for guidelines. labels May 19, 2026
@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

PR summary dd364d5681

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

+ bar
+ id_eq'

You can run this locally as follows
## from your `mathlib4` directory:
git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci

## summary with just the declaration names:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
../mathlib-ci/scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh in the mathlib-ci repository contains some details about this script.


No changes to strong technical debt.
No changes to weak technical debt.

@github-actions github-actions Bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label May 19, 2026
@grunweg
grunweg force-pushed the tofun-warn-redundant-name branch from e30fe47 to 78dad02 Compare May 19, 2026 23:51
@grunweg
grunweg force-pushed the tofun-warn-redundant-name branch from 78dad02 to fd0f0cd Compare May 20, 2026 06:53
Comment thread MathlibTest/ToFun.lean Outdated
@grunweg grunweg removed the WIP Work in progress label May 22, 2026
@grunweg
grunweg requested a review from JovanGerb May 22, 2026 02:18
@JovanGerb

Copy link
Copy Markdown
Contributor

The warning message is different from the one used in to_additive. Wouldn't it be better to use the same phrasing?

@grunweg

grunweg commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

Sure, but which one should be used?

Comment thread Mathlib/Tactic/ToFun.lean Outdated
@thorimur

Copy link
Copy Markdown
Contributor

Thanks! Looks good. :)

maintainer merge

@github-actions

Copy link
Copy Markdown

🚀 Pull request has been placed on the maintainer queue by thorimur.

@mathlib-triage mathlib-triage Bot added the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label May 27, 2026
@thorimur thorimur changed the title feat(Tactic/ToFun): warn if the provided name matches the autogenerat… feat(Tactic/ToFun): warn if provided name matches autogenerated one May 27, 2026
@thorimur

Copy link
Copy Markdown
Contributor

(Edited the title and PR description :) )

@adomani

adomani commented May 28, 2026

Copy link
Copy Markdown
Contributor

This is not part of this PR, but what happens if you use _root_.Foo.bar_fun? I suspect that the check will not warn, but you add a declaration whose name that starts with _root_. in the environment!

@adomani

adomani commented May 28, 2026

Copy link
Copy Markdown
Contributor

Thanks!

bors merge

@mathlib-triage mathlib-triage Bot added the ready-to-merge This PR has been sent to bors. label May 28, 2026
@mathlib-triage mathlib-triage Bot removed the maintainer-merge A reviewer has approved the changed; awaiting maintainer approval. label May 28, 2026
mathlib-bors Bot pushed a commit that referenced this pull request May 28, 2026
…39598)

This PR advises the user to remove a name they explicitly provided to `@[to_fun]` if it matches the name `@[to_fun]` would autogenerate.
@mathlib-bors

mathlib-bors Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors Bot changed the title feat(Tactic/ToFun): warn if provided name matches autogenerated one [Merged by Bors] - feat(Tactic/ToFun): warn if provided name matches autogenerated one May 28, 2026
@mathlib-bors mathlib-bors Bot closed this May 28, 2026
@grunweg
grunweg deleted the tofun-warn-redundant-name branch May 28, 2026 09:40
@grunweg

grunweg commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

root.Foo.bar_fun

Indeed, good catch! (And to_additive has the same issue.) Should this be disallowed, or should the _root_ be dropped --- what do you think?

@adomani

adomani commented May 28, 2026

Copy link
Copy Markdown
Contributor

I am not sure: I think that, if it were banned, no current use would get flagged. However, if it gets banned, I am not sure how you could signal the legitimate desire of "place the to_additive declaration in the root namespace"...

@grunweg

grunweg commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Indeed, I just arrived at the same conclusion (and found another bug in the naming generation).
Should @[to_fun _root_.bar] instead just generate the name bar, i.e. overriding the namespace length heuristic?

@grunweg

grunweg commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

I have made #39962 with that fix

grunweg added a commit to grunweg/mathlib4 that referenced this pull request May 30, 2026
…eanprover-community#39598)

This PR advises the user to remove a name they explicitly provided to `@[to_fun]` if it matches the name `@[to_fun]` would autogenerate.
b-mehta pushed a commit to b-mehta/mathlib4 that referenced this pull request Jun 2, 2026
…eanprover-community#39598)

This PR advises the user to remove a name they explicitly provided to `@[to_fun]` if it matches the name `@[to_fun]` would autogenerate.
Bergschaf pushed a commit to Bergschaf/mathlib4 that referenced this pull request Jun 3, 2026
…eanprover-community#39598)

This PR advises the user to remove a name they explicitly provided to `@[to_fun]` if it matches the name `@[to_fun]` would autogenerate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

easy < 20s of review time. See the lifecycle page for guidelines. ready-to-merge This PR has been sent to bors. t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants