With the $(command) form, all characters following the open
parenthesis to the matching closing parenthesis constitute the
command. Any valid shell script can be used for command, except a
script consisting solely of redirections which produces unspecified
results.

I suspect that the part of the text that I have highlighted in bold font is responsible for causing unspecified behaviour in the above examples. However, I am not entirely sure because I couldn't find a definition for "a script consisting solely of redirections" in the standard.

I have two questions.

Can we prove with sufficient references to the standard or man
pages whether the output of

ksh

in the first example is a bug or
not?

How else can I capture the standard error written by a shell
function where the shell function is performing command
substitution?