|
1 | 1 | import Mathlib.Tactic.Linter.Lint
|
2 | 2 | import Mathlib.Tactic.ToAdditive
|
| 3 | +import Mathlib.Order.SetNotation |
3 | 4 |
|
4 | 5 | -- TODO: the linter also runs on the #guard_msg, so disable it once
|
5 | 6 | -- See https://leanprover.zulipchat.com/#narrow/stream/348111-std4/topic/.23guard_msgs.20doesn't.20silence.20warnings/near/423534679
|
@@ -87,6 +88,126 @@ note: this linter can be disabled with `set_option linter.cdot false`
|
87 | 88 | set_option linter.cdot true in
|
88 | 89 | example : Add Nat where add := (. + ·)
|
89 | 90 |
|
| 91 | +set_option linter.dollarSyntax false in |
| 92 | +/-- |
| 93 | +warning: Please use '<|' instead of '$' for the pipe operator. |
| 94 | +note: this linter can be disabled with `set_option linter.dollarSyntax false` |
| 95 | +--- |
| 96 | +warning: Please use '<|' instead of '$' for the pipe operator. |
| 97 | +note: this linter can be disabled with `set_option linter.dollarSyntax false` |
| 98 | +-/ |
| 99 | +#guard_msgs in |
| 100 | +set_option linter.dollarSyntax true in |
| 101 | +attribute [instance] Int.add in |
| 102 | +instance (f g : Nat → Nat) : Inhabited Nat where |
| 103 | + default := by |
| 104 | + · have := 0 |
| 105 | + · have : Nat := f $ g $ 0 |
| 106 | + · exact 0 |
| 107 | + |
| 108 | +section lambdaSyntaxLinter |
| 109 | + |
| 110 | +set_option linter.style.lambdaSyntax false |
| 111 | + |
| 112 | +/-- |
| 113 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 114 | +The 'λ' syntax is deprecated in mathlib4. |
| 115 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 116 | +-/ |
| 117 | +#guard_msgs in |
| 118 | +set_option linter.style.lambdaSyntax true in |
| 119 | +example : ℕ → ℕ := λ _ ↦ 0 |
| 120 | + |
| 121 | +/-- |
| 122 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 123 | +The 'λ' syntax is deprecated in mathlib4. |
| 124 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 125 | +-/ |
| 126 | +#guard_msgs in |
| 127 | +set_option linter.style.lambdaSyntax true in |
| 128 | +def foo : Bool := by |
| 129 | + let _f : ℕ → ℕ := λ _ ↦ 0 |
| 130 | + exact true |
| 131 | + |
| 132 | +example : ℕ → ℕ := fun n ↦ n - 1 |
| 133 | + |
| 134 | +/-- |
| 135 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 136 | +The 'λ' syntax is deprecated in mathlib4. |
| 137 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 138 | +-/ |
| 139 | +#guard_msgs in |
| 140 | +set_option linter.style.lambdaSyntax true in |
| 141 | +example : ℕ → ℕ := by exact λ n ↦ 3 * n + 1 |
| 142 | + |
| 143 | +/-- |
| 144 | +warning: declaration uses 'sorry' |
| 145 | +--- |
| 146 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 147 | +The 'λ' syntax is deprecated in mathlib4. |
| 148 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 149 | +--- |
| 150 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 151 | +The 'λ' syntax is deprecated in mathlib4. |
| 152 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 153 | +--- |
| 154 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 155 | +The 'λ' syntax is deprecated in mathlib4. |
| 156 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 157 | +-/ |
| 158 | +#guard_msgs in |
| 159 | +set_option linter.style.lambdaSyntax true in |
| 160 | +example : ℕ → ℕ → ℕ → ℕ := by |
| 161 | + have (n : ℕ) : True := trivial |
| 162 | + have : (Set.univ : Set ℕ) = ⋃ (i : ℕ), (Set.iUnion λ j ↦ ({0, j} : Set ℕ)) := sorry |
| 163 | + have : ∃ m : ℕ, ⋃ i : ℕ, (Set.univ : Set ℕ) = ∅ := sorry |
| 164 | + exact λ _a ↦ fun _b ↦ λ _c ↦ 0 |
| 165 | + |
| 166 | +/-- |
| 167 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 168 | +The 'λ' syntax is deprecated in mathlib4. |
| 169 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 170 | +--- |
| 171 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 172 | +The 'λ' syntax is deprecated in mathlib4. |
| 173 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 174 | +--- |
| 175 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 176 | +The 'λ' syntax is deprecated in mathlib4. |
| 177 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 178 | +-/ |
| 179 | +#guard_msgs in |
| 180 | +set_option linter.style.lambdaSyntax true in |
| 181 | +example : True := by |
| 182 | + have : 0 = 0 ∧ 0 = 0 ∧ 1 + 3 = 4 := by |
| 183 | + refine ⟨by trivial, by |
| 184 | + let _f := λ n : ℕ ↦ 0; |
| 185 | + have : ℕ := by |
| 186 | + · -- comment |
| 187 | + · have := λ k : ℕ ↦ -5 |
| 188 | + · exact 0 |
| 189 | + refine ⟨by trivial, have := λ k : ℕ ↦ -5; by simp⟩ |
| 190 | + ⟩ |
| 191 | + trivial |
| 192 | + |
| 193 | +-- Code such as the following would require walking the infotree instead: |
| 194 | +-- the inner set_option is ignore (in either direction). |
| 195 | +-- As this seems unlikely to occur by accident and its use is dubious, we don't worry about this. |
| 196 | +/-- |
| 197 | +warning: Please use 'fun' and not 'λ' to define anonymous functions. |
| 198 | +The 'λ' syntax is deprecated in mathlib4. |
| 199 | +note: this linter can be disabled with `set_option linter.style.lambdaSyntax false` |
| 200 | +-/ |
| 201 | +#guard_msgs in |
| 202 | +set_option linter.style.lambdaSyntax true in |
| 203 | +example : ℕ → ℕ := set_option linter.style.lambdaSyntax false in λ _ ↦ 0 |
| 204 | + |
| 205 | +set_option linter.style.lambdaSyntax false |
| 206 | +#guard_msgs in |
| 207 | +example : ℕ → ℕ := set_option linter.style.lambdaSyntax true in λ _ ↦ 0 |
| 208 | + |
| 209 | +end lambdaSyntaxLinter |
| 210 | + |
90 | 211 | set_option linter.dollarSyntax false in
|
91 | 212 | /--
|
92 | 213 | warning: Please use '<|' instead of '$' for the pipe operator.
|
|
0 commit comments