-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareregressionswift 5.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Previous ID | SR-10305 |
Radar | rdar://problem/49609518 |
Original Reporter | calebkleveter (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
Environment
Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)
Target: x86_64-apple-darwin18.5.0
Additional Detail from JIRA
Votes | 2 |
Component/s | Compiler |
Labels | Bug, 5.0Regression, CompilerCrash, TypeChecker |
Assignee | calebkleveter (JIRA) |
Priority | Medium |
md5: e4a5f8345ebf8ab1fdd4181d3edcf4df
is duplicated by:
- SR-10493 compiler crasher on [Substring].map(Int.init)
- SR-10561 Compiler crash Type Checker
- SR-10784 Compiler crash: Segmentation fault
Issue Description:
The Swift 5 type checker is crashing with a segfault when I try to convert an optional Substring to an Int:
public struct Version {
public init?(_ string: String) {
let components: [Substring] = string.split(separator: ".")
guard let major: Int = components.first.flatMap(Int.init) else { return nil }
}
}
The program compiles if I map over the Substring array and convert them so Strings.
Here is the gist with the compiler output: https://gist.github.com/calebkleveter/e6a7f3943b50e022ecd2beefbed44a6e
The crash occurs in both Xcode and the Terminal.
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareregressionswift 5.0type checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis