mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Currently we don't insert an intermediate `SyntacticElement` locator element for the `if` statement in a SingleValueStmtExpr, which leads to an assertion failure when attempting to simplify a following `TernaryBranch` element. Move the insertion of the `SyntacticElement` locator element for the statement into the SingleValueStmtExpr constraint generation function, and remove it from the statement visitors themselves. For the other cases, the `SyntacticElement` was already being inserted for children of a BraceStmt, so we were actually previously ending up with duplicated elements in a couple of places.
21 lines
346 B
Swift
21 lines
346 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// https://github.com/apple/swift/issues/71282
|
|
|
|
enum E {
|
|
case e
|
|
}
|
|
|
|
// Make sure we don't crash.
|
|
func foo(_ x: E) {
|
|
return if .random() {
|
|
()
|
|
switch x {
|
|
case .e:
|
|
()
|
|
}
|
|
} else { // expected-error {{non-expression branch of 'if' expression may only end with a 'throw'}}
|
|
()
|
|
}
|
|
}
|