Skip to content

False positive for prefer_self_in_static_references when an inner struct has the same name as its owner #5917

@mildm8nnered

Description

@mildm8nnered

New Issue Checklist

Bug Description

struct S1 {
    struct S1 {}
    var s = S1()
}

prefer_self_in_static_references will report a violation at var s = S1(), but S1 here refers to the inner struct, not the outer one, so var s= Self() would be different, and would fail if the inner S1 has different properties to the outer one.

As a workaround,

struct S1 {
    struct S1 {}
    var s = Self.S1()
}

Has the same effect, but does not trigger prefer_self_in_static_references.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected and reproducible misbehavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions