-
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 softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution
Description
| Previous ID | SR-13018 |
| Radar | rdar://problem/64953119 |
| Original Reporter | @mbrandonw |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, RunTimeCrash |
| Assignee | @slavapestov |
| Priority | Medium |
md5: 2c03afa2034e8d179cd73102ecf6a551
Issue Description:
Consider the following method:
struct T<A> {
func run<C>(_ c: C) where C: Collection, C.SubSequence == A {
print(c[...] as! A)
}
}This should restrict the collection passed into `run` to be such that its subsequence matches the generic A.
For example, these following compile just fine:
// These should compile ✅
T<Substring>().run("")
T<Data>().run(Data())However, there seem to be some situations where we can pass in a collection that does not match this constraint and yet it still compiles, and hence crashes at runtime:
// These should not but do⁉️
T<Substring>().run(Data())
T<Data>().run("")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 softwarerun-time crashBug → crash: Swift code crashed during executionBug → crash: Swift code crashed during execution