Files
codeql/swift/ql/test/extractor-tests/generated/stmt/SwitchStmt/switch.swift
Paolo Tranquilli f22d60f011 Swift: clean up VarDecl, NamedPattern and SwitchStmt interactions
* `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`.
2023-10-23 17:36:42 +02:00

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
}