mirror of
https://github.com/github/codeql.git
synced 2026-08-04 01:13:00 +02:00
* `variables` under `CaseStmt` are now AST children, which solves orphan `VarDecl`s in that case * reordered `CaseStmt` AST children to be `labels > variables > body` (was `body > labels`) * made `NamedPattern::getVarDecl` an extracted property instead of `getName` * The above led to duplicate DB entities because of a quirk in the Swift compiler code. This is solved by tweaking the extraction of `variables` under `CaseStmt` to not use `getCaseBodyVariables`.
43 lines
630 B
Swift
43 lines
630 B
Swift
let index = 42
|
|
switch index {
|
|
case 1:
|
|
print("1")
|
|
fallthrough
|
|
case 5, 10:
|
|
print("5, 10")
|
|
case let x where x >= 42:
|
|
print("big")
|
|
default:
|
|
print("default")
|
|
}
|
|
|
|
enum X {
|
|
case one
|
|
case two(_: Int, _: String)
|
|
case three(s: String)
|
|
}
|
|
|
|
let x = X.two(42, "foo")
|
|
switch x {
|
|
case .one:
|
|
break
|
|
case .two(let a, let b) where a == b.count:
|
|
break
|
|
case .two(let c, let d):
|
|
break
|
|
case .three(s: let e):
|
|
break
|
|
}
|
|
|
|
outer: switch x {
|
|
case .two(let a, _):
|
|
inner: switch a {
|
|
case 0:
|
|
break outer
|
|
default:
|
|
break inner
|
|
}
|
|
default:
|
|
break
|
|
}
|