mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fixes: https://bugs.swift.org/browse/SR-3455 https://bugs.swift.org/browse/SR-3663 https://bugs.swift.org/browse/SR-4032 https://bugs.swift.org/browse/SR-4031 Now, compilation conditions are validated at first, then evaluated. Also, in non-Swift3 mode, '&&' now has higher precedence than '||'. 'A || B && C || D' are evaluated as 'A || (B && C) || D'. Swift3 source breaking changes: * [SR-3663] This used to be accepted and evaluate to 'true' because of short circuit without any validation. #if true || true * 12 = try Anything is OK? print("foo") #endif In this change, remaining expressions are properly validated and diagnosed if it's invalid. * [SR-4031] Compound name references are now diagnosed as errors. e.g. `#if os(foo:bar:)(macOS)` or `#if FLAG(x:y:)` Swift3 compatibility: * [SR-3663] The precedence of '||' and '&&' are still the same and the following code evaluates to 'true'. #if false || true && false print("foo") #endif
24 lines
585 B
Swift
24 lines
585 B
Swift
// RUN: %target-typecheck-verify-swift -swift-version 4
|
|
|
|
#if false || true && false
|
|
undefinedIf()
|
|
#else
|
|
undefinedElse() // expected-error {{use of unresolved identifier 'undefinedElse'}}
|
|
#endif
|
|
|
|
#if false && true || true
|
|
undefinedIf() // expected-error {{use of unresolved identifier 'undefinedIf'}}
|
|
#else
|
|
undefinedElse()
|
|
#endif
|
|
|
|
#if false || true && false || false
|
|
undefinedIf()
|
|
#else
|
|
undefinedElse() // expected-error {{use of unresolved identifier 'undefinedElse'}}
|
|
#endif
|
|
|
|
// expected-error @+1 {{invalid conditional compilation expression}}
|
|
#if false || true && try! Swift
|
|
#endif
|