I've heard this "don't name a number first" advice so many times, but personally, it never seems to work. My current comp is significantly higher compared to others with my level of experience. So when I refuse to give a number, the recruiter ends up guessing a number that is significantly lower, and making a lowball offer. I've also had many other experiences where after many hours of interviews, I find out that the…
If the offer comes in way too low, you can choose at that point to give your current salary. If you gave the current salary in beginning, you can't take back that bit of information.
(That said, I completely agree that it is generally good advice to not disclose your salary expectations in most cases. This is especially true for junior hackers without full awareness of the market conditions, who I have seen consistently underestimate their salary potential.)