Skip to content

type inference problem with captured type in closures #23618

@sbromberger

Description

@sbromberger
function foo(a::AbstractVector)
    T = eltype(a)
    b = Vector{T}()
    c = [Set{T}() for x in a]
    return length(c)
end

a = rand(1:10, 200);

@code_warntype shows an inference failure in b and c.

Changing to c = Set{T}[Set{T}() for x in a] fixes c's inference issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions