Skip to content

Sum of a Queue is type unstable #619

@HenriDeh

Description

@HenriDeh

Example :

julia> using DataStructures

julia> q=Queue{Float64}()
Queue{Float64}(Deque [Float64[]])

julia> enqueue!(q, 0)
Queue{Float64}(Deque [[0.0]])

julia> enqueue!(q, 1)
Queue{Float64}(Deque [[0.0, 1.0]])

julia> enqueue!(q, 3)
Queue{Float64}(Deque [[0.0, 1.0, 3.0]])

julia> @code_warntype sum(q)
Variables
  #self#::Core.Compiler.Const(sum, false)
  a::Queue{Float64}

Body::Any
1 ─ %1 = Base.sum(Base.identity, a)::Any
└──      return %1
```

Same for Deque:

```
@code_warntype sum(q.store)
Variables
  #self#::Core.Compiler.Const(sum, false)
  a::Deque{Float64}

Body::Any
1 ─ %1 = Base.sum(Base.identity, a)::Any
└──      return %1
```

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