lean4-htt/tests/lean/interactive/errorExplanationInteractive.lean
jrr6 e5c6fe1dac
feat: add elaborators, completions, and hovers for named errors (#8730)
This PR adds support for throwing named errors with associated error
explanations. In particular, it adds elaborators for the syntax defined
in #8649, which use the error-explanation infrastructure added in #8651.
This includes completions, hovers, and jump-to-definition for error
names.

Note that another stage0 rebuild will be required to define explanations
using `register_error_explanation`.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
Co-authored-by: Marc Huisinga <mhuisi@protonmail.com>
2025-06-18 15:51:34 +00:00

41 lines
1.1 KiB
Text

import Lean.ErrorExplanation
import Lean.Exception
import Lean.Log
/-!
# Error explanation interactive tests
Tests completions and hovers for error explanations.
-/
/-- Example -/
register_error_explanation TestDomain.Bar {
summary := "Error 0"
sinceVersion := "4.0.0"
}
/-- Example -/
register_error_explanation TestDomain.Foo1 {
summary := "Error 1"
sinceVersion := "4.0.0"
}
/-- Example -/
register_error_explanation TestDomain.Foo2 {
summary := "Error 2"
sinceVersion := "4.0.0"
}
#check throwNamedError TestDomain
--^ textDocument/completion
#check throwNamedError TestDomain.
--^ textDocument/completion
#check throwNamedError TestDomain.F
--^ textDocument/completion
#check throwNamedError TestDomain.F "test"
--^ textDocument/completion
#check throwNamedError TestDomain.Foo2
--^ textDocument/hover
#check throwNamedError TestDomain.Foo2 "test"
--^ textDocument/hover