`broadcast` behaves differently for tuples and arrays

I was surprised to find that broadcast behaves differently for tuples and arrays:

julia> ((x,y) -> @show x,y).((:a,),[1,2]);
(x, y) = (:a, 1)
(x, y) = (:a, 2)

julia> ((x,y) -> @show x,y).((:a,),(1,2));
(x, y) = (:a, 1)

Is this difference intended? It somewhat complicates things here.

On 0.7, these work the same.

2 Likes

and:

((x,y) -> @show x,y).([:a,],(1,2));
(x, y) = (:a, 1)
(x, y) = (:a, 2)

or if we change order:

((x,y) -> @show x,y).((1,2),[:a]);
(x, y) = (1, :a)
(x, y) = (2, :a)

((x,y) -> @show x,y).((1,2),(:a,));
(x, y) = (1, :a)
ERROR: BoundsError: attempt to access (:a,)
  at index [2]
Stacktrace:
 [1] (::Base.Broadcast.##3#4{##98#99,Tuple{Tuple{Int64,Int64},Tuple{Symbol}}})(::Int64) at ./broadcast.jl:339
 [2] broadcast(::Function, ::Tuple{Int64,Int64}, ::Tuple{Symbol}) at ./broadcast.jl:434

Just tried it in julia 0.7 as available in Julia Box, and I still get the same result as in 0.6.

julia> ((x,y) -> @show x,y).((:a,),[1,2]);
(x, y) = (:a, 1)
(x, y) = (:a, 2)

julia> ((x,y) -> @show x,y).((:a,),(1,2));
(x, y) = (:a, 1)
(x, y) = (:a, 2)

julia> versioninfo()
Julia Version 0.7.0-DEV.2523
Commit c317f90f0d* (2017-11-20 12:22 UTC)