Files
swift-mirror/test/Parse/trailing-comma-experimental.swift
Daniel Rodríguez Troitiño ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00

85 lines
2.6 KiB
Swift

// RUN: %target-typecheck-verify-swift -enable-experimental-feature TrailingComma
// REQUIRES: swift_feature_TrailingComma
// Condition List
func testConditionListTrailingComma() {
if true, { }
if true, { }; { }()
if true, { print("if-body") } else { print("else-body") }
if true, { print("if-body") } else if true, { print("else-if-body") } else { print("else-body") }
if true, { if true { { } } } // expected-error {{closure expression is unused}} expected-note {{did you mean to use a 'do' statement?}}
{ if true, { print(0) } } // expected-error {{closure expression is unused}} expected-note {{did you mean to use a 'do' statement?}}
( if true, { print(0) } ) // expected-error {{'if' may only be used as expression in return, throw, or as the source of an assignment}} expected-error {{'if' must have an unconditional 'else' to be used as expression}}
if true, {true}(), { }
if true, { true }, { print(0) } // expected-error {{function produces expected type 'Bool'; did you mean to call it with '()'?}}
if true, { print(0) }
{ }()
if true, { true } // expected-error {{function produces expected type 'Bool'; did you mean to call it with '()'?}}
,{ print(0) }
if true, { (x: () -> Void) in true } != nil { print(0) } // expected-warning {{comparing non-optional value of type '(() -> Void) -> Bool' to 'nil' always returns true}}
if true, { (x: () -> Void) in true }
!= nil // expected-warning {{comparing non-optional value of type '(() -> Void) -> Bool' to 'nil' always returns true}}
{
print(0)
}
if { } // expected-error {{missing condition in 'if' statement}}
if , { } // expected-error {{expected expression, var, or let in 'if' condition}}
guard else { return } // expected-error {{missing condition in 'guard' statement}}
guard , else { return } // expected-error {{expected expression, var, let or case in 'guard' condition}}
guard true, else { return }
guard true, , else { return } // expected-error {{expected expression in conditional}}
guard true, { return } // expected-error {{expected 'else' after 'guard' condition}}
while true, { }
}
// Switch Case Pattern List
switch 5 {
case 1, 2,:
break
default:
break
}
protocol P1 { }
protocol P2 { }
// Generic Where Clause List
struct S1<T1, T2,> where T1: P1, T2: P2, { }
protocol P3 {
func f<T1, T2>(a: T1, b: T2) where T1: P1, T2: P2, // expected-error {{expected type}}
}
// Inheritance Clause List
struct S2: P1, P2, { }
struct S3<T>: P1, P2, where T: Equatable { }
protocol P4 {
associatedtype T: P1, P2, // expected-error {{expected type}}
}