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-2538] swiftc doesn't give helpful errors when names of generic variables collide #45143

Closed
swift-ci opened this issue Sep 1, 2016 · 0 comments

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 1, 2016

Previous ID SR-2538
Radar None
Original Reporter der_fab (JIRA User)
Type Improvement
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement
Assignee None
Priority Medium

md5: de650db9b70e1da7de898bbd35a07b8a

duplicates:

  • SR-1420 Provide compiler warning when shadowing generic type

Issue Description:

> swiftc --version
Apple Swift version 2.2 (swiftlang-703.0.18.8 clang-703.0.31)
Target: x86_64-apple-macosx10.9
> cat StrangeError.swift 
class Provider<T> {
   func strange<T>() -> Provider<T> {
       return self
   }
}
> swiftc StrangeError.swift 
StrangeError.swift:3:15: error: cannot convert return expression of type 'Provider<T>' to return type 'Provider<T>'
       return self
              ^~~~

The problem in this code is that method strange introduces a second generic type variable named T. The error message referes to two different type variables, but this is not apparent. It would be more robust if swiftc either warns if type variables are overwritten or to forbid (in a future revision of the language) to overwrite type variables.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant