Files
swift-mirror/test/Parse/if-else-invalid.swift
Anthony Latsis 012675b303 [6.2] Cherry-pick "[test] Bring back accidentally deleted test case in..."
...https://github.com/swiftlang/swift/pull/81280. The deleted test was
`test/FixCode/fixits-if-else.swift`. Resurrect it in a better place and
switch it to the diagnostic verifier, as it was intended to along with
other moved tests in that PR.

(cherry picked from commit 8928b538b3)
2025-05-07 17:35:23 +01:00

45 lines
916 B
Swift

// RUN: %target-swift-frontend -parse -verify %s
// No more diags expected during Sema.
// RUN: %target-typecheck-verify-swift
do {
func something() -> Bool {}
func foo() {}
do {
if something() {
// expected-error@+1:11 {{expected '{' or 'if' after 'else'}}{{none}}
} else
}
do {
if something() {
// expected-error@+1:11 {{expected '{' or 'if' after 'else'}}{{none}}
} else
foo()
}
do {
if something() {
// expected-error@+1:7 {{expected '{' or 'if' after 'else'; did you mean to write 'if'?}}{{11-11= if}}
} else something() { // Fix-it because all on one line.
}
}
do {
if something() {
// expected-error@+1:12 {{expected '{' or 'if' after 'else'}}{{none}}
} else something()
{
}
}
do {
if something() {
// expected-error@+1:12 {{expected '{' or 'if' after 'else'}}{{none}}
} else something()
foo1()
}
}