Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
typesanitizer opened this issue Dec 14, 2020 · 0 comments
Open

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

typesanitizer opened this issue Dec 14, 2020 · 0 comments
Labels
compiler The Swift compiler in itself improvement type checker Area → compiler: Semantic analysis

Comments

@typesanitizer
Copy link

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.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

1 participant