lean.invalidField
This error indicates that an expression containing a dot followed by an identifier was encountered, and that it wasn't possible to understand the identifier as a field.
Lean's field notation is very powerful, but this can also make it confusing: the expression
color.value can either be a single identifier,
it can be a reference to the field of a structure, and it
and be a calling a function on the value color with
generalized field notation.
Examples
Incorrect Field Name
Projecting from the Wrong Expression
The type of the expression before the dot entirely determines the function being called by the field
projection. There is no Char.leftpad, and the only way to invoke List.leftpad with generalized
field notation is to have the list come before the dot.
Type is Not Specific
def double_plus_one {α} [Add α] (x : α) :=
(x + x).succ
def double_plus_one (x : Nat) :=
(x + x).succ
The Add typeclass is sufficient for performing the addition x + x, but the .succ field notation
cannot operate without knowing more about the actual type from which succ is being projected.
Insufficient Type Information
example := fun (n) => n.succ.succ
example := fun (n : Nat) => n.succ.succ
Generalized field notation can only be used when it is possible to determine the type that is being projected. Type annotations may need to be added to make generalized field notation work.