fix grammar to allow more expressions in matrix literal
add implicit coerce of boolean to boolean
add implicit casts to function return values and var declarations

While variable assignments already do this, variable declarations with
a value did not yet cast the value to the expected type. Also, functions
should return objects of exactly the type their return type.