Asking someone whether or not they can do the job isn't discrimination. Asking someone if they know something basically unrelated to the job might well be. It could be designed to filter out people who wouldn't know that thing rather than filter in people who'd be better at the job. What is that if it isn't discrimination?
I can stretch your logic even further that giving BE task to FE person is a discrimination because they don't have luxury to work on BE. Why do we discriminate against QA people who don't have luxury to work on dev jobs? Why do we discriminate against people who don't work as developers at all?