mojira.dev
MC-313499

`/debug function` now always throws a `ClassCastException`

Steps to reproduce:

  1. Create a world with a data pack containing any function (an empty .mcfunction is enough).

  2. Run /debug function <namespace>:<function>.

Observed:
Chat shows "An unexpected error occurred trying to execute that command". The hover text reads "class net.minecraft.commands.ParseContext$Simple cannot be cast to class net.minecraft.commands.CommandSourceStack". No stack trace appears in latest.log. /function works normally.

Expected:
The function is traced and the result is written to debug/.

Affected versions:
Fails in 26.4 Snapshot 8, 9 and 10. Works in 26.4 Snapshot 6 and 7.

Notes:
In decompiled bytecode, FunctionCommand$FunctionCustomExecutor.runGuarded calls getTopContext().copyFor(source) before resolving the function argument. DebugCommand$TraceCustomExecutor.runGuarded does not, so the context still carries a ParseContext$Simple as its source when FunctionArgument.getFunction casts it to CommandSourceStack.

Attachments

Comments 1

Thank you for helping us improve Minecraft! We saved your files:

[media]

serval7227

(Unassigned)

Confirmed

26.4 Snapshot 10

Retrieved