mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The parser is supposed to avoid looking inside unmatched `#if` compiler (et al) blocks. This usually means that the following code builds fine #if compiler(>=100) foo bar #endif however, a logical bug meant that if the check was nested inside an already-inactive `#if` block, it would not adhere to this evaluation-skipping behavior #if false #if compiler(>=100) foo bar // error! #endif #endif This PR fixes this specific case.
49 lines
705 B
Swift
49 lines
705 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
// RUN: %target-typecheck-verify-swift -swift-version 4
|
|
|
|
#if !compiler(>=4.1)
|
|
// There should be no error here.
|
|
foo bar
|
|
#else
|
|
let _: Int = 1
|
|
#endif
|
|
|
|
#if compiler(<4.1)
|
|
// There should be no error here.
|
|
foo bar
|
|
#else
|
|
let _: Int = 1
|
|
#endif
|
|
|
|
#if (compiler(>=4.1))
|
|
let _: Int = 1
|
|
#else
|
|
// There should be no error here.
|
|
foo bar
|
|
#endif
|
|
|
|
#if !compiler(<4.1)
|
|
let _: Int = 1
|
|
#else
|
|
// There should be no error here.
|
|
foo bar
|
|
#endif
|
|
|
|
#if compiler(>=4.1)
|
|
let _: Int = 1
|
|
#else
|
|
#if false
|
|
// There should be no error here.
|
|
foo bar
|
|
#endif
|
|
#endif
|
|
|
|
#if false
|
|
#if compiler(>=4.1)
|
|
let _: Int = 1
|
|
#else
|
|
// There should be no error here.
|
|
foo bar
|
|
#endif
|
|
#endif
|