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-13554] Misleading error "cannot assign value of type 'T' to type 'T'" for shadowed generic type #55991

Open
regexident opened this issue Sep 16, 2020 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis

Comments

@regexident
Copy link
Contributor

Previous ID SR-13554
Radar rdar://problem/68993160
Original Reporter @regexident
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: 905ab060d96abfd26a4e6fec0bd2fd11

Issue Description:

The following code:

struct Foo<T> {
    let t: T
    
    init<T>(t: T) {
        self.t = t
    }
}

… produces the following error:

// error: cannot assign value of type 'T' to type 'T'
//     self.t = t
//          ^
//            as! T

The error message here is bad: It should hint at T being shadowed.

The as! T is also gonna lead to more problems, rather than less. I can count the times that adding a force cast solved a random compilation error on a single hand.

@typesanitizer
Copy link

@swift-ci create

@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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants