This PR improves the error messages produced by invalid projections and field notation. It also adds a hint to the "function expected" error message noting the argument to which the term is being applied, which can be helpful for debugging spurious "function expected" messages actually caused by syntax errors. --------- Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
38 lines
875 B
Text
38 lines
875 B
Text
import Lean.Meta
|
|
|
|
/-!
|
|
# Tests for the `inlineExpr` function
|
|
|
|
`inlineExpr` should print the given expression inline, unless it exceeds a given length, in which
|
|
case it is moved to an indented block.
|
|
-/
|
|
|
|
open Lean Meta
|
|
|
|
opaque shortFun : Nat → Nat
|
|
opaque shortConst : Nat
|
|
|
|
def runTest (e : Expr) : MetaM Unit := do
|
|
let msg := inlineExpr e (maxInlineLength := 30)
|
|
logInfo m!"Before{msg}After"
|
|
|
|
def testShort : MetaM Unit := do
|
|
runTest <| .app (.const ``shortFun []) (.const ``shortConst [])
|
|
|
|
/-- info: Before `shortFun shortConst` After -/
|
|
#guard_msgs in
|
|
#eval testShort
|
|
|
|
opaque functionWithLongName : Nat → Nat
|
|
opaque constantWithLongName : Nat
|
|
|
|
def testLong : MetaM Unit := do
|
|
runTest <| .app (.const ``functionWithLongName []) (.const ``constantWithLongName [])
|
|
|
|
/--
|
|
info: Before
|
|
functionWithLongName constantWithLongName
|
|
After
|
|
-/
|
|
#guard_msgs in
|
|
#eval testLong
|