feat: warn on inexact deprecations - #14600
Conversation
|
The adaptation PR for this PR is leanprover/downstream-lean4#21. |
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
|
@wkrozowski If you have a minute, I'd appreciate your review on the meta code. |
| private def areTypesReduciblyDefEq (decl₁ decl₂ : ConstantInfo) : MetaM Bool := do | ||
| if decl₁.numLevelParams != decl₂.numLevelParams then | ||
| return false | ||
| let levels := decl₁.levelParams.mapIdx fun i _ => mkLevelParam <| Name.num `_deprecated i |
There was a problem hiding this comment.
How do we deal with permuted universe parameters?
For example:
myDef.{u,v} : Type u -> Type v -> Prop
myDef.{v,u} : Type v -> Type u -> Prop
Also, if we have the same level params, why are we substituting them?
There was a problem hiding this comment.
If the level parameters are permuted, then we consider the type changed.
Also, if we have the same level params, why are we substituting them?
Not sure if I'm following your question here. The problem this is solving is that
theorem foo (a : Type u) : 1 = 1 := rfl
theorem bar (a : Type v) : 1 = 1 := rflwere considered to have different types and this caused a decent number of false positives.
There was a problem hiding this comment.
Okay, that makes sense. I was a bit confused, as this reminded me of the related problems I had when adding a hint/code action to deprecated linter, and had to make sure that the replacement would be sound.
For the second one, this also makes sense to me.
There was a problem hiding this comment.
I genuinely do think that I should wait for this PR to be merged, until I finish #14525, as I could use the information about the preservation of types there.
| let hint ← if let some insertPos := insertPos? then | ||
| MessageData.hint "Add `+typeChanged`:" #[{ | ||
| suggestion := " +typeChanged" | ||
| messageData? := some "+typeChanged" | ||
| span? := Syntax.ofRange ⟨insertPos, insertPos⟩ | ||
| diffGranularity := .none | ||
| toCodeActionTitle? := some fun _ => "Try this: +typeChanged" | ||
| }] | ||
| else | ||
| pure <| MessageData.hint' "Add `+typeChanged` to silence this warning." |
There was a problem hiding this comment.
Could you check if this correctly displays a code action by the way? (assuming it is branched off from master, when code actions PR was merged)
There was a problem hiding this comment.
Yes, I have already used the code action many times :)
This PR adds a warning when deprecating a declaration in favor of another declaration that is not reducibly defeq.
Here is the warning in full:
The majority of the diff is removing deprecated declarations which would have triggered this warning but are overdue for removal anyway.