Skip to content

Commit 2042dc1

Browse files
committed
[test] Add additional if expr test
1 parent ad10c72 commit 2042dc1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/expr/unary/if_expr.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,7 @@ func continue1() -> Int {
933933
func return1() -> Int {
934934
// Make sure we always reject a return.
935935
let i = if .random() {
936+
()
936937
do {
937938
for _ in [0] {
938939
while true {
@@ -1504,6 +1505,11 @@ dynamic func testDynamicOpaqueErase() -> some EraserP {
15041505
if .random() { SomeEraserP() } else { SomeEraserP() }
15051506
}
15061507

1508+
struct NonExhaustiveProperty {
1509+
let i = if .random() { 0 }
1510+
// expected-error@-1 {{'if' must have an unconditional 'else' to be used as expression}}
1511+
}
1512+
15071513
// MARK: Out of place if exprs
15081514

15091515
func inDefaultArg(x: Int = if .random() { 0 } else { 0 }) {}

0 commit comments

Comments
 (0)