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-11295] There should be a warning for unnecessary casts #53696

Open
swift-ci opened this issue Aug 12, 2019 · 7 comments
Open

[SR-11295] There should be a warning for unnecessary casts #53696

swift-ci opened this issue Aug 12, 2019 · 7 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Aug 12, 2019

Previous ID SR-11295
Radar None
Original Reporter cukier (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterBug
Assignee None
Priority Medium

md5: 134fdcf76ae60512bbc5e443ad8390d7

Issue Description:

Swift should warn you if you're performing a cast to a type that the thing is already

        let a = "Hello"
        _ = a as String

I would expect something like "casting expression to `String` doesn't change the type" with a fixit of removing "as String"

@harlanhaskins
Copy link
Collaborator

@harlanhaskins harlanhaskins commented Aug 14, 2019

This sounds like a good starter bug!

@LucianoPAlmeida
Copy link
Collaborator

@LucianoPAlmeida LucianoPAlmeida commented Aug 17, 2019

I can give it a try @harlanhaskins

@LucianoPAlmeida
Copy link
Collaborator

@LucianoPAlmeida LucianoPAlmeida commented Aug 17, 2019

@harlanhaskins Here's the PR #26710 🙂

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Aug 20, 2019

Comment by Sidramappa Halake (JIRA)

Unnecessary casting, there should be warning

@MartinP7r
Copy link

@MartinP7r MartinP7r commented Nov 15, 2020

Hi everyone.

This Issues's status is still `open` although the PR has been merged over a year ago.

#27880

Can we close it? Sorry if I'm missing the point or anything, but navigating things here is still very confusing.

I'm searching through the Starterbugs in order to find something easy to start contributing on. If someone has a suggestion for a beginner, I'd really appreciate it!

@LucianoPAlmeida
Copy link
Collaborator

@LucianoPAlmeida LucianoPAlmeida commented Nov 15, 2020

The merge was reverted because of a case we have not handled and we hit a behavior that needs to get right on the compiler in order for us to be able to correctly implement this. Long history short we need a way to track down from where(the source) of an inferred type is coming from. You can see more details on the re-apply PR #27895 As far as stater bug you can checkout this link and check for any unassigned 🙂

@MartinP7r
Copy link

@MartinP7r MartinP7r commented Nov 15, 2020

Thank you! �

@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
Projects
None yet
Development

No branches or pull requests

4 participants