Zulip Chat Archive

Stream: lean4

Topic: Bug in `deprecated` linter


Yury G. Kudryashov (Jan 12 2024 at 07:13):

Here is an #mwe

@[deprecated] def Implies (p q : Prop) := p  q

def MyNS.Implies (α : Type) (p q : α  Prop) : Prop :=
   x, p x  q x

open MyNS

namespace MyNS2

example (h : Implies Nat (fun _  True) fun _  False) : False :=
  h 0 trivial

In this example, Lean says that Implies is deprecated but in fact this is the non-deprecated MyNS.Implies.

Damiano Testa (Jan 12 2024 at 07:35):

Slight minimization:

@[deprecated] def Implies (_p : Unit) := True

def MyNS.Implies := True

open MyNS

example (h : Implies) : True := h

Yury G. Kudryashov (Jan 12 2024 at 08:01):

Note: if the definition is in namespace MyNS, then everything works fine. It fails only with open MyNS; probably, because it tried to unify _root_.Implies too (and failed) but this is just a guess.

Mario Carneiro (Jan 12 2024 at 08:01):

this is a known issue, I recall there being a comment about it in the code

Mario Carneiro (Jan 12 2024 at 08:02):

https://github.com/leanprover/lean4/blob/ad068824d05878da799567f0ae56b4048eef9022/src/Lean/Elab/Term.lean#L1602

    Linter.checkDeprecated declName -- TODO: check is occurring too early if there are multiple alternatives. Fix if it is not ok in practice

Mario Carneiro (Jan 12 2024 at 08:06):

in short, whenever lean has to use typing to differentiate between ambiguous name resolutions, it can potentially mark things as deprecated before it has committed to one of the possibilities, so you see phantom warnings from parses that didn't make the cut

Yury G. Kudryashov (Jan 12 2024 at 08:06):

Thank you.

Yury G. Kudryashov (Jan 12 2024 at 08:07):

I'll just use full name.


Last updated: May 02 2025 at 03:31 UTC