The /return run when applied to a fork and a /function that doesn't return causes different behavior depending whether it is run in chat, inside of a function or using /debug function.
How to reproduce:
The attached data pack contains a function called bugtest:test with the following command:
execute as @e[tag=selected] run return run function bugtest:test2
The function bugtest:test2 is a small function that just contains the command "say Test" and doesn't return.
Now spawn multiple entities with the tag "selected", e.g. using the following command:
summon armor_stand ~ ~ ~ {Tags:["selected"]}
Then run the following commands:
The command above directly in chat (the one with /return run)
/function bugtest:test
/debug function bugtest:test
Observed behavior:
1. and 3. The message "Test" appears for every entity spawned.
2. The message "Test" appears once and the function returns.
Expected behavior:
In all of the cases the message should only be shown once and return since /return run is supposed to always return.
Confirmed.
Clearer steps to reproduce:
Install the attached data pack.
Run the following command twice:
Run
/execute as @e[tag=selected] run return run function bugtest:test2
->❌ "Test" appears in chat twice
Run
/function bugtest:test
-> ✔ "Test" appears in chat once
Run
/debug function bugtest:test
-> ❌ "Test" appears in chat twice
Expected result:
"Test" appears in chat once for all instances due to
return run
being used.