Attempting to have a player run a function containing the /spawnpoint command from a custom enchantment does not set a new spawnpoint.
Steps to Reproduce:
Create a custom enchantment inside of a datapack.
Make the enchantment run a function containing the /spawnpoint command as an effect by the "hit_block" effect.
activate the enchantment on a tool.
run /kill command
Observed results: Player respawns at world spawn
Expected Results: Player should spawn at location that the /spawnpoint command was ran from.
Notes: Attached are the custom enchantment and function included. The other two commands work as intended. Running the function in game manually will set the player's spawn properly.
Please attach a datapack as a .zip file so we can easily reproduce the issue