Skip to content

zip() returns scalar instead of tuple when passed a single argument in 0.4 #13979

@nalimilan

Description

@nalimilan

Is this intended or a regression?

In 0.3:

julia> i = zip(1:2)
Zip{(UnitRange{Int64},)}((1:2,))

julia> start(i)
(1,)

julia> next(i, (1,))
((1,),(2,))

In 0.4:

julia> i = zip(1:2)
2-element UnitRange{Int64}:
 1,2

julia> start(i)
1

julia> next(i, 1)
(1,2)

This means you cannot handle single-argument and multiple-argument cases with the same code. I encountered this issue when doing something similar to:

function (x...) 
...
    vtypes = map(eltype, typeof(x).parameters)
    d = Dict{Tuple{vtypes...}, Any}()
    for el in zip(x...)
        # Error in convert()
        d[el] = true
    end
...
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions