mojira.dev
MC-267194

/return run function in combination with a fork and a function that doesn't return has inconsistent behavior

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:

  1. The command above directly in chat (the one with /return run)

  2. /function bugtest:test

  3. /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.

Attachments

Comments 2

Confirmed.

Clearer steps to reproduce:

  1. Install the attached data pack.

  2. Run the following command twice:

    /summon armor_stand ~ ~ ~ {Tags:["selected"]}
  3. Run /execute as @e[tag=selected] run return run function bugtest:test2
    ->❌ "Test" appears in chat twice

  4. Run /function bugtest:test
    -> ✔ "Test" appears in chat once

  5. 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.

Can confirm in 1.20.4

Rob23

(Unassigned)

Community Consensus

Platform

Normal

Commands, Data Packs

1.20.4 Release Candidate 1, 1.20.4

23w51a

Retrieved