-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
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 itself
Description
| Previous ID | SR-11160 |
| Radar | rdar://problem/53312914 |
| Original Reporter | @Kelvin13 |
| Type | Bug |
| Status | Resolved |
| Resolution | Done |
Environment
$ swift --version
Swift version 5.1-dev (LLVM 200186e28b, Swift 75a5496)
Target: x86_64-unknown-linux-gnu
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug |
| Assignee | @typesanitizer |
| Priority | Medium |
md5: 17cc87614deb65870fadbaf0dd67d61d
is blocked by:
- SR-11212 Ill-typed patterns are permitted to compile (implicit tupling/untupling)
Issue Description:
why does this work:
{{}}
func foo<T, U>(_ bar1:T?, _ bar2:U?)
{
switch (bar1, bar2)
{
case (let a?, let b?):
print(a, b)
case (let a?, nil):
print(a, -1)
case(nil, let b?):
print(-1, b)
case (nil, nil):
print("")
}
}{{}}
but not this?
switch (Optional<Int>(1), Optional<(Int, Int)>((5, 6)))
{
case (let a?, let b?):
print(a, b)
case (let a?, nil):
print(a, -1)
case(nil, let b?):
print(-1, b)
case (nil, nil):
print("")
} error: switch must be exhaustive
switch (Optional<Int>(1), Optional<(Int, Int)>((5, 6)))
^
note: add missing case: '(_, .some(_, _))'
switch (Optional<Int>(1), Optional<(Int, Int)>((5, 6))) {{}}
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 itself