Skip to content

Generator Type Instability #43330

@longqian95

Description

@longqian95
function t1()
    p=zeros(2)
    m=minimum(p[i] for i=1:2)
    p=zeros(2)
    return m
end
function t2()
    p=zeros(2)
    m=minimum(p[i] for i=1:2)
    return m
end

@code_warntype t1() will show it is type unstable. However, t2 is type stable.

Maybe related to #18695. But looks strange because t1 and t2 are indeed the same.

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