Depending on escape analysis, the array underlying the slice can get allocated on the stack as well, if it doesn't escape the function context. Of course, in this case, because we are returning a pointer to it via the slice, that optimization isn't applicable.
Agreed that it could in principle. But I can't immediately get it to do so: https://go.dev/play/p/9hLHattS8cf
Both arrays in this example seem to be on the heap.