This PR implements a linter that warns when a deprecated coercion is applied. It also warns when the `Option` coercion or the `Subarray`-to-`Array` coercion is used in `Init` or `Std`. The linter is currently limited to `Coe` instances; `CoeFun` instances etc. are not considered. The linter works by collecting the `Coe` instance declaration names that are being expanded in `expandCoe?` and storing them in the info tree. The linter itself then analyzes the info tree and checks for banned or deprecated coercions.
85 lines
5.2 KiB
Text
85 lines
5.2 KiB
Text
[Elab.info]
|
|
• [Command] @ ⟨3, 0⟩-⟨3, 31⟩ @ Lean.Elab.Command.elabSetOption
|
|
• [Completion] (Command.set_option "set_option" `trace.Elab.info []) @ ⟨3, 0⟩-⟨3, 26⟩
|
|
• [Option] trace.Elab.info @ ⟨3, 11⟩-⟨3, 26⟩
|
|
1 + 2 + 3 : Nat
|
|
[Elab.info]
|
|
• [Command] @ ⟨5, 0⟩-⟨5, 16⟩ @ Lean.Elab.Command.elabCheck
|
|
• [Term] 1 + 2 + 3 : Nat @ ⟨5, 7⟩-⟨5, 16⟩ @ «_aux_Init_Notation___macroRules_term_+__2»
|
|
• [MacroExpansion]
|
|
1 + 2 +
|
|
3
|
|
-- should propagate through multiple macro expansions
|
|
|
|
===>
|
|
binop% HAdd.hAdd✝ (1 + 2)
|
|
3
|
|
-- should propagate through multiple macro expansions
|
|
|
|
• [Term] 1 + 2 + 3 : Nat @ ⟨5, 7⟩†-⟨5, 16⟩† @ Lean.Elab.Term.Op.elabBinOp
|
|
• [Term] 1 + 2 + 3 : Nat @ ⟨5, 7⟩†-⟨5, 16⟩†
|
|
• [Term] 1 + 2 : Nat @ ⟨5, 7⟩-⟨5, 12⟩ @ «_aux_Init_Notation___macroRules_term_+__2»
|
|
• [MacroExpansion]
|
|
1 + 2
|
|
===>
|
|
binop% HAdd.hAdd✝ 1 2
|
|
• [Term] 1 + 2 : Nat @ ⟨5, 7⟩†-⟨5, 12⟩†
|
|
• [Completion-Id] HAdd.hAdd✝ : none @ ⟨5, 7⟩†-⟨5, 16⟩†
|
|
• [Completion-Id] HAdd.hAdd✝ : none @ ⟨5, 7⟩†-⟨5, 12⟩†
|
|
• [Term] 1 : Nat @ ⟨5, 7⟩-⟨5, 8⟩ @ Lean.Elab.Term.elabNumLit
|
|
• [Term] 2 : Nat @ ⟨5, 11⟩-⟨5, 12⟩ @ Lean.Elab.Term.elabNumLit
|
|
• [Term] 3 : Nat @ ⟨5, 15⟩-⟨5, 16⟩ @ Lean.Elab.Term.elabNumLit
|
|
fun n m l => ↑n + (↑m + ↑l) : Nat → Nat → Nat → Int
|
|
[Elab.info]
|
|
• [Command] @ ⟨7, 0⟩-⟨7, 48⟩ @ Lean.Elab.Command.elabCheck
|
|
• [Term] fun n m l => ↑n + (↑m + ↑l) : Nat → Nat → Nat → Int @ ⟨7, 7⟩-⟨7, 48⟩ @ Lean.Elab.Term.elabFun
|
|
• [Term] Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] Nat : some Sort.{?_uniq} @ ⟨7, 20⟩-⟨7, 23⟩
|
|
• [Term] Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩
|
|
• [Term] n (isBinder := true) : Nat @ ⟨7, 12⟩-⟨7, 13⟩
|
|
• [Term] Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] Nat : some Sort.{?_uniq} @ ⟨7, 20⟩-⟨7, 23⟩
|
|
• [Term] Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩
|
|
• [Term] m (isBinder := true) : Nat @ ⟨7, 14⟩-⟨7, 15⟩
|
|
• [Term] Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] Nat : some Sort.{?_uniq} @ ⟨7, 20⟩-⟨7, 23⟩
|
|
• [Term] Nat : Type @ ⟨7, 20⟩-⟨7, 23⟩
|
|
• [Term] l (isBinder := true) : Nat @ ⟨7, 16⟩-⟨7, 17⟩
|
|
• [Term] ↑n + (↑m + ↑l) : Int @ ⟨7, 28⟩-⟨7, 48⟩ @ Lean.Elab.Term.elabTypeAscription
|
|
• [Term] Int : Type @ ⟨7, 44⟩-⟨7, 47⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] Int : some Sort.{?_uniq} @ ⟨7, 44⟩-⟨7, 47⟩
|
|
• [Term] Int : Type @ ⟨7, 44⟩-⟨7, 47⟩
|
|
• [Term] ↑n + (↑m + ↑l) : Int @ ⟨7, 29⟩-⟨7, 41⟩ @ «_aux_Init_Notation___macroRules_term_+__2»
|
|
• [MacroExpansion]
|
|
n + (m +' l)
|
|
===>
|
|
binop% HAdd.hAdd✝ n (m +' l)
|
|
• [Term] ↑n + (↑m + ↑l) : Int @ ⟨7, 29⟩†-⟨7, 41⟩† @ Lean.Elab.Term.Op.elabBinOp
|
|
• [CustomInfo(Lean.Elab.Term.CoeExpansionTrace)]
|
|
• [CustomInfo(Lean.Elab.Term.CoeExpansionTrace)]
|
|
• [CustomInfo(Lean.Elab.Term.CoeExpansionTrace)]
|
|
• [Term] ↑n + (↑m + ↑l) : Int @ ⟨7, 29⟩†-⟨7, 41⟩†
|
|
• [Completion-Id] HAdd.hAdd✝ : none @ ⟨7, 29⟩†-⟨7, 41⟩†
|
|
• [Term] n : Nat @ ⟨7, 29⟩-⟨7, 30⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] n : none @ ⟨7, 29⟩-⟨7, 30⟩
|
|
• [Term] n : Nat @ ⟨7, 29⟩-⟨7, 30⟩
|
|
• [Term] ↑m + ↑l : Int @ ⟨7, 34⟩-⟨7, 40⟩ @ «_aux_lean_binopInfoTree___macroRules_term_+'__1»
|
|
• [MacroExpansion]
|
|
m +' l
|
|
===>
|
|
m + l
|
|
• [Term] ↑m + ↑l : Int @ ⟨7, 34⟩†-⟨7, 40⟩† @ «_aux_Init_Notation___macroRules_term_+__2»
|
|
• [MacroExpansion]
|
|
m + l
|
|
===>
|
|
binop% HAdd.hAdd✝ m l
|
|
• [Term] ↑m + ↑l : Int @ ⟨7, 34⟩†-⟨7, 40⟩†
|
|
• [Completion-Id] HAdd.hAdd✝ : none @ ⟨7, 34⟩†-⟨7, 40⟩†
|
|
• [Term] m : Nat @ ⟨7, 34⟩-⟨7, 35⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] m : none @ ⟨7, 34⟩-⟨7, 35⟩
|
|
• [Term] m : Nat @ ⟨7, 34⟩-⟨7, 35⟩
|
|
• [Term] l : Nat @ ⟨7, 39⟩-⟨7, 40⟩ @ Lean.Elab.Term.elabIdent
|
|
• [Completion-Id] l : none @ ⟨7, 39⟩-⟨7, 40⟩
|
|
• [Term] l : Nat @ ⟨7, 39⟩-⟨7, 40⟩
|
|
[Elab.info]
|
|
• [Command] @ ⟨8, 0⟩-⟨8, 0⟩ @ Lean.Elab.Command.elabEoi
|