You might find useful information in Sending, inout sending, Mutex in which I recently asked similar questions and got helpful answers!
I think in this case, it's because the compiler doesn't know how many times the closure passed to withTaskGroup
will be called — if withTaskGroup
called it twice, it would alias your NonSendable value.