Loot table functions are supposed to be able to have conditions inside them. However, this doesn't work, all conditions are ignored.
1. Download and open the attached world. It makes creepers drop diamond swords on death, which should be enchanted when killed by a player
2. Summon a creeper 30 blocks in the air
It should drop a normal diamond sword
It drops an enchanted diamond sword, even though it wasn't killed by a player.