E0004Type mismatch
Reported by the compiler as an error or warning.
mettle explain E0004
A value of one type was used where a different type is required. Mettle never infers var/local const binding types, so both sides must line up.
Example
var x: int64 = "hello"; // expected 'int64', found 'string'
Fixes
change the declared type to match the value, or the value to match the type
for numeric conversions, cast explicitly: (int32)value
Integers are the exception, and only in one direction: a conversion that every value survives happens on its own (int32 -> int64), and one that can change the value needs the cast. Those report M0119 rather than this code, so mettle explain M0119 has the rule.
Type and Field are compile-time reflection values (a TypeRef is a type-table index; a FieldRef is {type_index, field_index}). They have no runtime representation and cannot escape into runtime code. Bind them with const and keep them at compile time.