Skip to content

[SR-13965] Warn on shadowed type parameters #56362

@typesanitizer

Description

@typesanitizer
Previous ID SR-13965
Radar rdar://problem/45735133
Original Reporter @typesanitizer
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, TypeChecker
Assignee None
Priority Medium

md5: 5db23a1c00e99b556cb85597f6d03045

Issue Description:

We allow shadowed type parameters, which can lead to confusing diagnostics.

struct S<T> {
    var t: T
    init<T>(_ myT : T) {
        t = myT // error: cannot assign value of type 'T' to type 'T'
    }
}

In this case, there are two rigid type variables, one for the outer parameter and one for the inner parameter, but since they are both rigid, they can't be equal.

Emitting a warning would guide the programmer to simplifying their code so that we can produce a better diagnostic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions