chore: improve error message

see #346
This commit is contained in:
Leonardo de Moura 2021-03-16 20:42:38 -07:00
parent 6d53202e0b
commit dd4fb3b71b
3 changed files with 8 additions and 1 deletions

View file

@ -553,7 +553,7 @@ private def resolveLValAux (e : Expr) (eType : Expr) (lval : LVal) : TermElabM L
| some (baseStructName, fullName) => pure $ LValResolution.const baseStructName structName fullName
| none =>
throwLValError e eType
m!"invalid field notation, '{fieldName}' is not a valid \"field\" because the environment does not contain '{Name.mkStr structName fieldName}'"
m!"invalid field '{fieldName}', the environment does not contain '{Name.mkStr structName fieldName}'"
-- search local context first, then environment
let searchCtx : Unit → TermElabM LValResolution := fun _ => do
let fullName := Name.mkStr structName fieldName

View file

@ -8,3 +8,6 @@ def a : SomeType := SomeType.x
end SomeType
#eval SomeType.b
def f (x : Nat) :=
x.z

View file

@ -1,3 +1,7 @@
346.lean:10:6-10:16: error: unknown constant 'SomeType.b'
346.lean:10:0-10:16: error: failed to synthesize
Lean.Eval ?m
346.lean:13:2-13:5: error: invalid field 'z', the environment does not contain 'Nat.z'
x
has type
Nat