You frequently read, nowadays, even in government publications, here and there, that it is illegal to ask a certain question in a certain situation.
As: it is illegal to ask what disability a person has, when they want to bring a service dog into a restaurant.
Or: it is illegal to ask someone, on a job interview, if they have ever been arrested.
Now, there may be legal reasons why it is best to avoid asking these questions. But I don't think it's correct that you are breaking the law merely by asking the questions. You may be opening the business up for some kind of discrimination lawsuit or penalty, but that's only if your reason for asking the question was for a forbidden discriminatory purpose.
I've noticed it's not usually lawyers who declare that a question is illegal. It's usually a worker with some basic training in how to keep their employer out of trouble.
Speech remains free, but can be evidence of intent,
and you may find yourself explaining what you meant.