Navigation Menu

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-13277] Misleading warning when casting Array to unrelated Array #55717

Closed
swift-ci opened this issue Jul 24, 2020 · 1 comment
Closed

[SR-13277] Misleading warning when casting Array to unrelated Array #55717

swift-ci opened this issue Jul 24, 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

@swift-ci
Copy link
Collaborator

Previous ID SR-13277
Radar None
Original Reporter cukier (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Version 12.0 beta (12A6159)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, TypeChecker
Assignee None
Priority Medium

md5: abca29e2d9975135fedd34a03ba0f110

duplicates:

  • SR-6192 Spurious "Cast from ... to unrelated type ... always fails" warning when implicitly converting an empty collection

Issue Description:

let x: [String] = []
let y = x as? [Int] // Cast from '[String]' to unrelated type '[Int]' always fails
print(y as Any) // Optional([]) 

Warning says that the cast always fails. It's not true. It should instead say

Cast from '[String]' to unrelated type '[Int]' always fails, unless the array is empty

@hamishknight
Copy link
Collaborator

This was recently fixed by #32716 🙂

This issue was closed.
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