How to declare sharedarray in local scope

Hi!

I want to use sharedArray without data movement.

So I write the following code.

using Distributed
addprocs(1)
A = SharedArray{ComplexF64,1}(fill(1,(10)));
@everywhere 2 A

But this code makes the error,

ERROR: On worker 2:
UndefVarError: `A` not defined

In a global scope, I have solution.

using Distributed
addprocs(1)
A = SharedArray{ComplexF64,1}(fill(1,(10)));
@spawnat(2,A)
@everywhere 2 A

This code don’t make an error.

But my problem is in local scope.

For example,

function ex2()
    A = SharedArray{ComplexF64,1}(fill(1,(10)));
    for w in workers()
        fetch(@spawnat(w,A))
    end
    remotecall_fetch(x->x,2,A)
    @everywhere 2 println(Base.@locals)
    @everywhere 2 A
    return 
end

This code makes the error,

ERROR: On worker 2:
UndefVarError: `A` not defined

I have no solution in local scope.