It's converting the bindvar to a varchar in order to do the comparison.
I'd say that it's probably not worth bothering to change the code to return a more immediately comprehensible error message.