Before looking for a possible following `=`
LilyPond has to have made a decision what type the token/expression
coming before that has. It cannot look at the type of a #... expression
before deciding to look for `=` but it can (and will) look at the type
of a $... expression.
Now syntax errors are comparatively unhelpful, so one could try to
tentatively accept an #... = ... expression anyway and then barf if the
expression type does not support it. The result would likely not be
worse for the user.