lean4-htt/tests/lean/run/guard_msgs.lean
Kyle Miller 627a0f308b
fix: add unused variables ignore function for #guard_msgs (#3931)
The `#guard_msgs` command already runs linters by virtue of using
`elabCommandTopLevel`, so linters should *not* be run on `#guard_msgs`
itself. While we could use a more general solution, of the linters the
unused variables linter is the noisiest one, and it's easy enough to
make it not report messages for `#guard_msgs`.
2024-04-17 15:30:17 +00:00

146 lines
2.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean.Elab.Command
#guard_msgs in
/-- error: unknown identifier 'x' -/
#guard_msgs in
example : α := x
/--
error: unknown identifier 'x'
---
error: ❌ Docstring on `#guard_msgs` does not match generated message:
error: unknown identifier 'x'
-/
#guard_msgs in
#guard_msgs in
example : α := x
#guard_msgs in
/-- warning: declaration uses 'sorry' -/
#guard_msgs in
example : α := sorry
#guard_msgs in
/-- warning: declaration uses 'sorry' -/
#guard_msgs(warning) in
example : α := sorry
/-- warning: declaration uses 'sorry' -/
#guard_msgs in
#guard_msgs(error) in
example : α := sorry
#guard_msgs in
#guard_msgs(drop warning) in
example : α := sorry
#guard_msgs in
#guard_msgs(error, drop warning) in
example : α := sorry
#guard_msgs in
/-- error: unknown identifier 'x' -/
#guard_msgs(error, drop warning) in
example : α := x
#guard_msgs in
/--
error: failed to synthesize instance
OfNat α 22
-/
#guard_msgs(error) in
example : α := 22
-- Trailing whitespace
/--
info: foo ⏎
bar
---
error: ❌ Docstring on `#guard_msgs` does not match generated message:
info: foo ⏎
bar
-/
#guard_msgs in
#guard_msgs in
run_meta Lean.logInfo "foo \nbar"
#guard_msgs in
/--
info: foo ⏎
bar
-/
#guard_msgs in
run_meta Lean.logInfo "foo \nbar"
/--
info: foo ⏎⏎
bar
---
error: ❌ Docstring on `#guard_msgs` does not match generated message:
info: foo ⏎⏎
bar
-/
#guard_msgs in
#guard_msgs in
run_meta Lean.logInfo "foo ⏎\nbar"
#guard_msgs in
/--
info: foo ⏎⏎
bar
-/
#guard_msgs in
run_meta Lean.logInfo "foo ⏎\nbar"
/-!
Lax whitespace
-/
/-- error: failed to synthesize DecidableEq (Nat → Nat) -/
#guard_msgs (whitespace := lax) in
#synth DecidableEq (Nat → Nat)
/-- error: failed to synthesize
DecidableEq (Nat → Nat) -/
#guard_msgs (whitespace := lax) in
#synth DecidableEq (Nat → Nat)
/-!
Sorting
-/
/--
info: A
---
info: B
-/
#guard_msgs (ordering := sorted) in
run_meta do Lean.logInfo "B"; Lean.logInfo "A"
/--
info: B
---
info: A
-/
#guard_msgs in
run_meta do Lean.logInfo "B"; Lean.logInfo "A"
/-!
Linter suppression
-/
set_option linter.unusedVariables true
/-- warning: unused variable `n` [linter.unusedVariables] -/
#guard_msgs in
example (n : Nat) : True := trivial
/-- warning: unused variable `n` [linter.unusedVariables] -/
#guard_msgs in
#guard_msgs (info) in
example (n : Nat) : True := trivial