This is not a bug - at least, not in the conventional way.
Why do you order melee troops to fire at closest? They can't fire anything and therefore advance to go into melee.
One may argue that the archers should stay put ... but the game cannot split up squads on its own and give those units individual orders, at least in general.
And here's where the bug
might be: Missile troops run out of ammo, and otherwise devoid of missiles, are supposed to resort to their secondardy (melee) weapon and advance into melee. Now, your longbowman
did have launchers and ammo, but the game failed to recognize this. Or maybe randomly fails to recognize this at times - maybe it does not check all units in the squad... .
However, what you saw is more a limitation of the game engine than a 'real' bug. A very realistic one, I must say - image some mediaval soldiers, half of them infantrymen, the other half longbowmen, all of a sudden squeezed into one squad .. I guess they would have been pretty confused
In short: If you want missile troops to fire at enemies, set up a missile squad and order it to fire.
That sometimes those Mavernian Slingers forget about their slings and charge even when on their own and set to fire, is another issue ... .