Dynamic array default value in task/function

Your second code example is correct. The BNF does not allow for assignment patterns with an empty set of elements. You could also do
'{default:0}
.

Earlier versions of SystemVerilog had some inconstantcies between assignment patterns and array concatenation involving queues that has since been cleaned up.