First of all, this isnt a bug, your worker is only trying to carry out your command the best it can which is to MINE.
Since the command is mining in general, it will try to mine whatever it can after the gold is out which is iron.
This could be fixed if you want by creating two seperate commands of mining gold and mining iron. Then when you press the MINE GOLD command, it will only try to mine gold and not just MINE in general after its done.