Polyester.jl icon indicating copy to clipboard operation
Polyester.jl copied to clipboard

UndefVarError: not defined

Open wly2014 opened this issue 3 years ago • 1 comments

This code will result an error LoadError: UndefVarError: a#259 not defined.

using Polyester
function test()
    a = zeros(3)
    @batch for i in 1:3
        if false
            a = zeros(3)
        end
        a[i] = 1.0
    end
end
test()

But it will be OK when I use Threads.@threads. Is it a bug?

Thank you very much.

wly2014 avatar Jul 04 '22 05:07 wly2014

Polyester tries very hard not to capture variables in closures. The a = inside the loop tells it not to take any as from the surrounding scope.

chriselrod avatar Jul 04 '22 05:07 chriselrod