Skip to content

Conversation

@JovanGerb
Copy link
Collaborator

@JovanGerb JovanGerb commented Jan 8, 2026

This PR refactors the linter in to_dual/to_additive for when you tag a declaration that already has a translation. Previously it threw an error that couldn't be turned off, and it would only do this when using the existing modifier. Now it also runs without the existing modifier, and it only throws a warning, which can also be turned off.

There was some hard coded stuff for allowing to correct the (reorder := ...) argument. I removed this code, which also has the side effect of making the syntax more consistent. In order to stay compatible with these cases, the linter doesn't complain when setting the translation to the same thing again.

See also #1779 which allowed to_additive on already existing translations


Open in Gitpod

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

PR summary 21cf59b03b

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff

No declarations were harmed in the making of this PR! 🐙

You can run this locally as follows
## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/declarations_diff.sh long <optional_commit>

The doc-module for script/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@mathlib4-merge-conflict-bot
Copy link
Collaborator

This pull request has conflicts, please merge master and resolve them.

@mathlib4-merge-conflict-bot mathlib4-merge-conflict-bot added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 9, 2026
@github-actions github-actions bot removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Jan 10, 2026
if tgt != tgt' then
Linter.logLintIf linter.translateOverwrite ref
m!"`{src}` was already translated to `{tgt'}` instead of `{tgt}`.\n\
Unless the original translation was wrong, please remove this `{t.attrName}` attribute."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a test that shows this new warning in action, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added one now

Copy link
Contributor

@bryangingechen bryangingechen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
bors r+

@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added the ready-to-merge This PR has been sent to bors. label Jan 12, 2026
mathlib-bors bot pushed a commit that referenced this pull request Jan 12, 2026
This PR refactors the linter in `to_dual`/`to_additive` for when you tag a declaration that already has a translation. Previously it threw an error that couldn't be turned off, and it would only do this when using the `existing` modifier. Now it also runs without the `existing` modifier, and it only throws a warning, which can also be turned off.

There was some hard coded stuff for allowing to correct the `(reorder := ...)` argument. I removed this code, which also has the side effect of making the syntax more consistent. In order to stay compatible with these cases, the linter doesn't complain when setting the translation to the same thing again.

See also #1779 which allowed `to_additive` on already existing translations
@mathlib-bors
Copy link
Contributor

mathlib-bors bot commented Jan 13, 2026

Pull request successfully merged into master.

Build succeeded:

@mathlib-bors mathlib-bors bot changed the title feat(translate): linter for overwriting existing translations [Merged by Bors] - feat(translate): linter for overwriting existing translations Jan 13, 2026
@mathlib-bors mathlib-bors bot closed this Jan 13, 2026
@adomani adomani mentioned this pull request Jan 16, 2026
eliasjudin pushed a commit to eliasjudin/mathlib4 that referenced this pull request Jan 18, 2026
…over-community#33777)

This PR refactors the linter in `to_dual`/`to_additive` for when you tag a declaration that already has a translation. Previously it threw an error that couldn't be turned off, and it would only do this when using the `existing` modifier. Now it also runs without the `existing` modifier, and it only throws a warning, which can also be turned off.

There was some hard coded stuff for allowing to correct the `(reorder := ...)` argument. I removed this code, which also has the side effect of making the syntax more consistent. In order to stay compatible with these cases, the linter doesn't complain when setting the translation to the same thing again.

See also leanprover-community#1779 which allowed `to_additive` on already existing translations
goliath-klein pushed a commit to PrParadoxy/mathlib4 that referenced this pull request Jan 24, 2026
…over-community#33777)

This PR refactors the linter in `to_dual`/`to_additive` for when you tag a declaration that already has a translation. Previously it threw an error that couldn't be turned off, and it would only do this when using the `existing` modifier. Now it also runs without the `existing` modifier, and it only throws a warning, which can also be turned off.

There was some hard coded stuff for allowing to correct the `(reorder := ...)` argument. I removed this code, which also has the side effect of making the syntax more consistent. In order to stay compatible with these cases, the linter doesn't complain when setting the translation to the same thing again.

See also leanprover-community#1779 which allowed `to_additive` on already existing translations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge This PR has been sent to bors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants