-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
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-14369 |
Radar | rdar://problem/75536455 |
Original Reporter | ensan (JIRA User) |
Type | Bug |
Environment
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin20.3.0
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 113d93ddba44a19aed68abb4e5d47b5d
Issue Description:
Consider following enum.
enum Either<T,S> {
case first(T)
case second(S)
}
This is normal usage:
let value = Either<Int, String>.first(42)
switch value{
case let .first(value):
print(value)
case let .second(value):
print(value)
}
However following also work. Obviously it is strange because enum doesn't have any labels.
switch value{
case let .first(aaaa: int):
print(int)
case let .second(bbbb: string):
print(string)
}
It's also happen with `if` and other statements with `case`.
if case let .first(aaaa: int) = value{
}
I don't know deeply about swift compiler, but it seems to be a bug of compiler.
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