Skip to content

Imprecise inference when iterating a Pair with constant first type but varying second type. #37610

Closed
@KristofferC

Description

@KristofferC
julia> a = ("foo" => "bar", "baz" => nothing);

julia> function f(a, i)
           y = iterate(a, i)
           if y !== nothing
               (k, v), st = y
               return k, v
           end
           return y
       end

julia> @code_warntype f(a, 1)

infers to Union{Nothing, Tuple{Union{Nothing, String},Union{Nothing, String}}} In particular, k is inferred as k::Union{Nothing, String} but it could maybe be inferrable as a String.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions