Skip to content

Commit

Permalink
fix: make proof_wanted not report unused variables (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmill authored Oct 17, 2024
1 parent 422d1a5 commit d011c00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Batteries/Util/ProofWanted.lean
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ elaboration, but it's then removed from the environment.
def elabProofWanted : CommandElab
| `($mods:declModifiers proof_wanted $name $args* : $res) => withoutModifyingEnv do
-- The helper axiom is used instead of `sorry` to avoid spurious warnings
elabCommand <| ← `(axiom helper (p : Prop) : p
$mods:declModifiers
theorem $name $args* : $res := helper _)
elabCommand <| ← `(
section
set_option linter.unusedVariables false
axiom helper {α : Sort _} : α
$mods:declModifiers theorem $name $args* : $res := helper
end)
| _ => throwUnsupportedSyntax
15 changes: 15 additions & 0 deletions test/proof_wanted.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Batteries.Util.ProofWanted

/-!
No unused variable warnings.
-/
#guard_msgs in proof_wanted foo (x : Nat) : True

/-!
When not a proposition, rely on `theorem` command failing.
-/
/--
error: type of theorem 'foo' is not a proposition
Nat → Nat
-/
#guard_msgs in proof_wanted foo (x : Nat) : Nat

0 comments on commit d011c00

Please sign in to comment.