Closed kg583 closed 6 months ago
Well, it's a TypeError
, not a SyntaxError
—it works for variables, but only variables that point to objects of the right type. Documentation could potentially be improved here, though.
it works for variables, but only variables that point to objects of the right type.
Except that's just not true, as my examples show, unless the message refers to the coefficient type (which is then still unclear).
Ah, yes, I see the confusion. It is referring to the first object in the expression (the coefficient in your examples).
Coefficient syntax errors raise the following message:
However, this message is too specific, as coefficient syntax can be applied to any variable, regardless of type:
It even parses fine the other way, with type checks distinguishing application and multiplication just fine:
All of this is to say that the error message could be improved to indicate that things are a bit more smart and relaxed than they seem. I'm not sure of a particular replacement yet, though, because the message does accurately relay the situation for literals.