@@ -25,22 +25,22 @@ import SwiftSyntax
2525/// - Returns: A pair of Boolean values and any diagnostics produced during the
2626/// evaluation. The first Boolean describes whether the condition holds with
2727/// the given build configuration. The second Boolean described whether
28- /// the build condition is a "versioned" check that implies that we shouldn't
28+ /// the build condition's failure implies that we shouldn't
2929/// diagnose syntax errors in blocks where the check fails.
3030func evaluateIfConfig(
3131 condition: ExprSyntax ,
3232 configuration: some BuildConfiguration
33- ) -> ( active: Bool , versioned : Bool , diagnostics: [ Diagnostic ] ) {
33+ ) -> ( active: Bool , syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
3434 var extraDiagnostics : [ Diagnostic ] = [ ]
3535
3636 /// Record the error before returning the given value.
3737 func recordError(
3838 _ error: any Error ,
3939 at node: some SyntaxProtocol
40- ) -> ( active: Bool , versioned : Bool , diagnostics: [ Diagnostic ] ) {
40+ ) -> ( active: Bool , syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
4141 return (
4242 active: false ,
43- versioned : true ,
43+ syntaxErrorsAllowed : true ,
4444 diagnostics: extraDiagnostics + error. asDiagnostics ( at: node)
4545 )
4646 }
@@ -49,7 +49,7 @@ func evaluateIfConfig(
4949 /// every 'throw' site in this evaluation.
5050 func recordError(
5151 _ error: IfConfigError
52- ) -> ( active: Bool , versioned : Bool , diagnostics: [ Diagnostic ] ) {
52+ ) -> ( active: Bool , syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
5353 return recordError ( error, at: error. syntax)
5454 }
5555
@@ -58,10 +58,10 @@ func evaluateIfConfig(
5858 func checkConfiguration(
5959 at node: some SyntaxProtocol ,
6060 body: ( ) throws -> ( Bool , Bool )
61- ) -> ( active: Bool , versioned : Bool , diagnostics: [ Diagnostic ] ) {
61+ ) -> ( active: Bool , syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
6262 do {
63- let ( active, versioned ) = try body ( )
64- return ( active, versioned , extraDiagnostics)
63+ let ( active, syntaxErrorsAllowed ) = try body ( )
64+ return ( active, syntaxErrorsAllowed , extraDiagnostics)
6565 } catch let error {
6666 return recordError ( error, at: node)
6767 }
@@ -71,7 +71,7 @@ func evaluateIfConfig(
7171 if let boolLiteral = condition. as ( BooleanLiteralExprSyntax . self) {
7272 return (
7373 active: boolLiteral. literalValue,
74- versioned : false ,
74+ syntaxErrorsAllowed : false ,
7575 diagnostics: extraDiagnostics
7676 )
7777 }
@@ -84,7 +84,7 @@ func evaluateIfConfig(
8484
8585 return (
8686 active: result,
87- versioned : false ,
87+ syntaxErrorsAllowed : false ,
8888 diagnostics: [
8989 IfConfigError . integerLiteralCondition (
9090 syntax: condition,
@@ -101,20 +101,20 @@ func evaluateIfConfig(
101101
102102 // Evaluate the custom condition. If the build configuration cannot answer this query, fail.
103103 return checkConfiguration ( at: identExpr) {
104- ( active: try configuration. isCustomConditionSet ( name: ident) , versioned : false )
104+ ( active: try configuration. isCustomConditionSet ( name: ident) , syntaxErrorsAllowed : false )
105105 }
106106 }
107107
108108 // Logical '!'.
109109 if let prefixOp = condition. as ( PrefixOperatorExprSyntax . self) ,
110110 prefixOp. operator. text == " ! "
111111 {
112- let ( innerActive, innerVersioned , innerDiagnostics) = evaluateIfConfig (
112+ let ( innerActive, innersyntaxErrorsAllowed , innerDiagnostics) = evaluateIfConfig (
113113 condition: prefixOp. expression,
114114 configuration: configuration
115115 )
116116
117- return ( active: !innerActive, versioned : innerVersioned , diagnostics: innerDiagnostics)
117+ return ( active: !innerActive, syntaxErrorsAllowed : innersyntaxErrorsAllowed , diagnostics: innerDiagnostics)
118118 }
119119
120120 // Logical '&&' and '||'.
@@ -123,26 +123,26 @@ func evaluateIfConfig(
123123 ( op. operator. text == " && " || op. operator. text == " || " )
124124 {
125125 // Evaluate the left-hand side.
126- let ( lhsActive, lhsVersioned , lhsDiagnostics) = evaluateIfConfig (
126+ let ( lhsActive, lhssyntaxErrorsAllowed , lhsDiagnostics) = evaluateIfConfig (
127127 condition: binOp. leftOperand,
128128 configuration: configuration
129129 )
130130
131131 // Short-circuit evaluation if we know the answer and the left-hand side
132- // was versioned .
133- if lhsVersioned {
132+ // was syntaxErrorsAllowed .
133+ if lhssyntaxErrorsAllowed {
134134 switch ( lhsActive, op. operator. text) {
135135 case ( true , " || " ) :
136- return ( active: true , versioned : lhsVersioned , diagnostics: lhsDiagnostics)
136+ return ( active: true , syntaxErrorsAllowed : lhssyntaxErrorsAllowed , diagnostics: lhsDiagnostics)
137137 case ( false , " && " ) :
138- return ( active: false , versioned : lhsVersioned , diagnostics: lhsDiagnostics)
138+ return ( active: false , syntaxErrorsAllowed : lhssyntaxErrorsAllowed , diagnostics: lhsDiagnostics)
139139 default :
140140 break
141141 }
142142 }
143143
144144 // Evaluate the right-hand side.
145- let ( rhsActive, rhsVersioned , rhsDiagnostics) = evaluateIfConfig (
145+ let ( rhsActive, rhssyntaxErrorsAllowed , rhsDiagnostics) = evaluateIfConfig (
146146 condition: binOp. rightOperand,
147147 configuration: configuration
148148 )
@@ -151,14 +151,14 @@ func evaluateIfConfig(
151151 case " || " :
152152 return (
153153 active: lhsActive || rhsActive,
154- versioned : lhsVersioned && rhsVersioned ,
154+ syntaxErrorsAllowed : lhssyntaxErrorsAllowed && rhssyntaxErrorsAllowed ,
155155 diagnostics: lhsDiagnostics + rhsDiagnostics
156156 )
157157
158158 case " && " :
159159 return (
160160 active: lhsActive && rhsActive,
161- versioned : lhsVersioned || rhsVersioned ,
161+ syntaxErrorsAllowed : lhssyntaxErrorsAllowed || rhssyntaxErrorsAllowed ,
162162 diagnostics: lhsDiagnostics + rhsDiagnostics
163163 )
164164
@@ -186,7 +186,7 @@ func evaluateIfConfig(
186186 func doSingleIdentifierArgumentCheck(
187187 _ body: ( String ) throws -> Bool ,
188188 role: String
189- ) -> ( active: Bool , versioned : Bool , diagnostics: [ Diagnostic ] ) {
189+ ) -> ( active: Bool , syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
190190 // Ensure that we have a single argument that is a simple identifier.
191191 guard let argExpr = call. arguments. singleUnlabeledExpression,
192192 let arg = argExpr. simpleIdentifierExpr
@@ -197,14 +197,14 @@ func evaluateIfConfig(
197197 }
198198
199199 return checkConfiguration ( at: argExpr) {
200- ( active: try body ( arg) , versioned : fn. isVersioned )
200+ ( active: try body ( arg) , syntaxErrorsAllowed : fn. syntaxErrorsAllowed )
201201 }
202202 }
203203
204204 /// Perform a check for a version constraint as used in the "swift" or "compiler" version checks.
205205 func doVersionComparisonCheck(
206206 _ actualVersion: VersionTuple
207- ) -> ( active: Bool , versioned : Bool , diagnostics: [ Diagnostic ] ) {
207+ ) -> ( active: Bool , syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
208208 // Ensure that we have a single unlabeled argument that is either >= or < as a prefix
209209 // operator applied to a version.
210210 guard let argExpr = call. arguments. singleUnlabeledExpression,
@@ -229,13 +229,13 @@ func evaluateIfConfig(
229229 case " >= " :
230230 return (
231231 active: actualVersion >= version,
232- versioned : fn. isVersioned ,
232+ syntaxErrorsAllowed : fn. syntaxErrorsAllowed ,
233233 diagnostics: extraDiagnostics
234234 )
235235 case " < " :
236236 return (
237237 active: actualVersion < version,
238- versioned : fn. isVersioned ,
238+ syntaxErrorsAllowed : fn. syntaxErrorsAllowed ,
239239 diagnostics: extraDiagnostics
240240 )
241241 default :
@@ -286,7 +286,7 @@ func evaluateIfConfig(
286286
287287 return (
288288 active: configuration. endianness == expectedEndianness,
289- versioned : fn. isVersioned ,
289+ syntaxErrorsAllowed : fn. syntaxErrorsAllowed ,
290290 diagnostics: extraDiagnostics
291291 )
292292
@@ -317,7 +317,7 @@ func evaluateIfConfig(
317317 fatalError ( " extraneous case above not handled " )
318318 }
319319
320- return ( active: active, versioned : fn. isVersioned , diagnostics: extraDiagnostics)
320+ return ( active: active, syntaxErrorsAllowed : fn. syntaxErrorsAllowed , diagnostics: extraDiagnostics)
321321
322322 case . swift:
323323 return doVersionComparisonCheck ( configuration. languageVersion)
@@ -353,7 +353,7 @@ func evaluateIfConfig(
353353
354354 return (
355355 active: configuration. compilerVersion >= expectedVersion,
356- versioned : fn. isVersioned ,
356+ syntaxErrorsAllowed : fn. syntaxErrorsAllowed ,
357357 diagnostics: extraDiagnostics
358358 )
359359
@@ -429,7 +429,7 @@ func evaluateIfConfig(
429429 importPath: importPath. map { String ( $0) } ,
430430 version: version
431431 ) ,
432- versioned : fn. isVersioned
432+ syntaxErrorsAllowed : fn. syntaxErrorsAllowed
433433 )
434434 }
435435 }
@@ -439,20 +439,20 @@ func evaluateIfConfig(
439439}
440440
441441extension IfConfigClauseSyntax {
442- /// Determine whether this condition is "versioned ".
443- func isVersioned (
442+ /// Determine whether this condition is "syntaxErrorsAllowed ".
443+ func syntaxErrorsAllowed (
444444 configuration: some BuildConfiguration
445- ) -> ( versioned : Bool , diagnostics: [ Diagnostic ] ) {
445+ ) -> ( syntaxErrorsAllowed : Bool , diagnostics: [ Diagnostic ] ) {
446446 guard let condition else {
447- return ( versioned : false , diagnostics: [ ] )
447+ return ( syntaxErrorsAllowed : false , diagnostics: [ ] )
448448 }
449449
450450 // Evaluate this condition against the build configuration.
451- let ( _, versioned , diagnostics) = evaluateIfConfig (
451+ let ( _, syntaxErrorsAllowed , diagnostics) = evaluateIfConfig (
452452 condition: condition,
453453 configuration: configuration
454454 )
455455
456- return ( versioned , diagnostics)
456+ return ( syntaxErrorsAllowed , diagnostics)
457457 }
458458}
0 commit comments