Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UndefVarError: not defined #84

Open
wly2014 opened this issue Jul 4, 2022 · 3 comments
Open

UndefVarError: not defined #84

wly2014 opened this issue Jul 4, 2022 · 3 comments

Comments

@wly2014
Copy link

wly2014 commented Jul 4, 2022

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.

@chriselrod
Copy link
Member

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.

@EpicDuckPotato
Copy link

I'm having a similar issue. Why does Polyester operate this way?

@chriselrod
Copy link
Member

I'm having a similar issue. Why does Polyester operate this way?

As a workaround for JuliaLang/julia#15276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants