Hi guys, not sure if this is the best forum for this question, but it kinda has to do in the context of world building, so I'm putting it here. If someone suggests otherwise, I'll get it moves elsewhere.

So, I have a setting that is largely dieselpunl in nature: automatic firearms, tanks, the like. However, it is also fantasy with all the magical creatures, magic, etc. To be more relevant, the most prominent enemy are hordes of demons, having spilled from the Abyss to basically wipe out everything.

As one may know, many demons are capable of teleporting and thus melee happens fairly often. As such, most soldiers are trained to be both proficient in melee weapon combat as well as firearms. My question is thus: what purpose would a bayonet serve in such a context? I feel most would carry a dedicated melee weapon like a sword. I know in real life bayonets of the era were to essentially turn a gun into a spear which is simple enough, but when a soldier is trained for a potentially superior weapon, why use the bayonet?

Maybe I'm just overthinking things and can easilly just scrap bayonets, but I admit I like the WH40K meme of "affix bayonets!" before charging into a melee or trench.

Thanks for your imput!