Skip to content

feat(Tactic/Translate): warn when adding a docstring to an existing declaration#41883

Open
gasparattila wants to merge 3 commits into
leanprover-community:masterfrom
gasparattila:translate-docstring-warning
Open

feat(Tactic/Translate): warn when adding a docstring to an existing declaration#41883
gasparattila wants to merge 3 commits into
leanprover-community:masterfrom
gasparattila:translate-docstring-warning

Conversation

@gasparattila

@gasparattila gasparattila commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

PR summary 457f039fa3

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference

Declarations diff (regex)

+ addStruct
+ addStruct'
+ mulStruct
+ mulStruct'
- mulTrivial'

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.

Declarations diff (Lean)

Lean-aware diff — post-build, computed from the Lean environment (commit 457f039).

  • +0 new declarations
  • −0 removed declarations

No declaration differences.


No changes to strong technical debt.

No changes to weak technical debt.

Current commit 457f039fa3
Reference commit ce279564d4

This script lives in the mathlib-ci repository. To run it locally, from your mathlib4 directory:

git clone https://github.com/leanprover-community/mathlib-ci.git ../mathlib-ci
../mathlib-ci/scripts/reporting/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).

@github-actions github-actions Bot added the t-meta Tactics, attributes or user commands label Jul 18, 2026
@plp127
plp127 requested a review from JovanGerb July 18, 2026 10:22

@JovanGerb JovanGerb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for making the PR. I would be in favour of an even stronger restriction: if the translation already exists, then we should always give this warning, whether or not there is already a doc-string. Because it is better to give the docstring immediately, rather than later via to_additive.

Comment thread Mathlib/Tactic/Translate/Core.lean Outdated
/-- An optional doc string. -/
doc : Option String := .none
/-- An optional doc string, together with its `Syntax` for logging warnings. -/
doc : Option (String × Syntax) := .none

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would make more sense to just store the Option Syntax, because we can simply get the string from the syntax.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

See #41886, which removes the deprecated "docstring" syntax and makes this field an Option (TSyntax _).

@gasparattila gasparattila changed the title feat(Tactic/Translate): warn when overwriting an existing docstring feat(Tactic/Translate): warn when adding a docstring to an existing declaration Jul 18, 2026
@gasparattila
gasparattila force-pushed the translate-docstring-warning branch from fbb2e5a to 457f039 Compare July 18, 2026 15:06
@mathlib-dependent-issues mathlib-dependent-issues Bot added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Jul 18, 2026
@mathlib-dependent-issues

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants