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-2585] Segmentation fault 11 when upcasting array of tuples #45190

Closed
swift-ci opened this issue Sep 8, 2016 · 4 comments
Closed

[SR-2585] Segmentation fault 11 when upcasting array of tuples #45190

swift-ci opened this issue Sep 8, 2016 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Sep 8, 2016

Previous ID SR-2585
Radar rdar://problem/28207648
Original Reporter bolismauro (JIRA User)
Type Bug
Status Closed
Resolution Done

Attachment: Download

Environment

Xcode Version 8.0 (8A218a)

Additional Detail from JIRA
Votes 2
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee bolismauro (JIRA)
Priority Medium

md5: 4625881c9c9c368e43acfaa902d54dc4

Issue Description:

This code makes the compiler crashes

protocol AnyV {}
struct V<G>: AnyV {}

protocol MyProtocol {
  associatedtype Key
  associatedtype Value
  
  static var variable: [(Key, V<Value>)] { get }
  
  static func useVariable()
}

extension MyProtocol {
  static func useVariable() {
    let v = self.variable as [(Key, AnyV)]
  }
}
@belkadan
Copy link
Contributor

belkadan commented Sep 8, 2016

I don't think the compiler considers that a valid upcast (from (Key, V<Value>) to (Key, AnyV)), though , but of course it shouldn't crash. Workaround: use map:

extension MyProtocol {
  static func useVariable() {
    let v = self.variable.map { ($0, $1) } as [(Key, AnyV)]
  }
}

@CodaFi
Copy link
Member

CodaFi commented Sep 18, 2016

Resolved by the merge of #4705

@rudkx
Copy link
Member

rudkx commented Sep 22, 2016

Mauro, can you verify with a recent build and close if it's fixed?

@swift-ci
Copy link
Collaborator Author

Comment by Mauro Bolis (JIRA)

It seems solved on my side

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
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 crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants