I'm fine with the not discriminating part, it's the asking part I'm concerned with. It seems like censorship and going against Freedom of Speech to me.
A better law would be that employers may not discriminate or refuse to hire someone if they refuse to tell them their previous salary.
Specificity is key, just saying you can't ask feels too overreaching. The intent is to prevent discrimination, not speech.