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

syntax error for single-kernel broadcast over splatted arguments ("multiple splatted args cannot be fused into a single broadcast") #26127

Closed
jrevels opened this issue Feb 20, 2018 · 2 comments
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:broadcast Applying a function over a collection domain:error handling Handling of exceptions by Julia or the user

Comments

@jrevels
Copy link
Member

jrevels commented Feb 20, 2018

julia> f(args...) = *(args...)
f (generic function with 1 method)

julia> x, y, z = (1,2), 3, (4, 5)
((1, 2), 3, (4, 5))

julia> f.(x..., y, z...)
ERROR: syntax: multiple splatted args cannot be fused into a single broadcast

julia> broadcast(f, x..., y, z...)
120

Seems like f.(...) here should just lower straight to broadcast(f, ...), since it's a straightforward syntactic transformation.

Is this an edge case that's just not handled correctly by the syntactic fusion code, or is the error intentional (perhaps there's an ambiguity here that I'm just missing)? At the very least, the error message should be changed - there's only a single kernel present, so there's no potential for fusion in the first place.

EDIT: edited example to avoid the syntactic fuser closing over the numeric literal (as mentioned by @mbauman)

@mbauman mbauman added broadcast compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:error handling Handling of exceptions by Julia or the user labels Feb 20, 2018
@mbauman
Copy link
Sponsor Member

mbauman commented Feb 20, 2018

Note that it is technically "fusing" the numeric literal into (as, bs)->f(as..., 2, bs...).

I do think it might be possible to handle multiple splats… it's probably just annoying and hard. Nope, I don't think fusion is possible with more than one splat by only changing the lowering. We'd need a _broadcast_apply function or similar, I think.

@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 20, 2018

Will be fixed by #25377 (when it is merged).

@mbauman mbauman added domain:broadcast Applying a function over a collection and removed broadcast labels Apr 24, 2018
Keno pushed a commit that referenced this issue Apr 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:broadcast Applying a function over a collection domain:error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

No branches or pull requests

3 participants