Steps to reproduce:
Create a world with a data pack containing any function (an empty
.mcfunctionis enough).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.
Thank you for helping us improve Minecraft! We saved your files: