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

Macro parsing incorrectly with OhMyThreads.@set #107

Closed
Moelf opened this issue May 27, 2024 · 3 comments · Fixed by #108
Closed

Macro parsing incorrectly with OhMyThreads.@set #107

Moelf opened this issue May 27, 2024 · 3 comments · Fixed by #108

Comments

@Moelf
Copy link

Moelf commented May 27, 2024

julia> function f()
           for i in [1,2,3]
               # check something
               OhMyThreads.@tasks for j in [1,2,3]
                   OhMyThreads.@set begin
                       scheduler = :static
                       ntasks = 8
                   end
                   j += 2
                   # do sutff
                   end
               end
           end
ERROR: LoadError: The @set macro may only be used inside of a @tasks block.

but this works:

julia> function f()
           for i in [1,2,3]
               # check something
               OhMyThreads.@tasks for j in [1,2,3]
                   @set begin
                       scheduler = :static
                       ntasks = 8
                   end
                   j += 2
                   # do sutff
                   end
               end
           end
f (generic function with 1 method)
@MasonProtter
Copy link
Member

MasonProtter commented May 27, 2024

Yeah, the @set macro is not a real macro. All it does is throw an error. It's only ever meant to be used as something that @tasks detects and handles, so when you write OhMyThreads.@set, it gets confused.

We can make it catch this particular pattern too, but it'll always be possible to confuse it, e.g. you could do

const var"@my_set" = var"@set"

and then try and use use @my_set inside @tasks and you'll get this same error.

@carstenbauer
Copy link
Member

carstenbauer commented May 27, 2024

What Mason said. But we should probably cover this particular pattern, i.e. OhMyThreads.@macroname, as well.

@Moelf
Copy link
Author

Moelf commented May 27, 2024

I'm aware of the mechanism that caused it and had seen the stub code in the macro definition. Not asking why though

carstenbauer added a commit that referenced this issue May 29, 2024
@carstenbauer carstenbauer mentioned this issue May 29, 2024
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

Successfully merging a pull request may close this issue.

3 participants