File tree 3 files changed +24
-2
lines changed 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ extension VersionTuple {
27
27
components = [ ]
28
28
29
29
// Version value are separated by periods.
30
- let componentStrings = versionString. split ( separator: " . " )
30
+ let componentStrings = versionString. split ( separator: " . " , omittingEmptySubsequences : false )
31
31
32
32
/// Record a component after checking its value.
33
33
func recordComponent( _ value: Int ) throws {
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public struct VersionTuple: Sendable {
33
33
public init ? ( parsing string: String ) {
34
34
self . components = [ ]
35
35
36
- for componentText in string. split ( separator: " . " ) {
36
+ for componentText in string. split ( separator: " . " , omittingEmptySubsequences : false ) {
37
37
guard let component = Int ( componentText) else {
38
38
return nil
39
39
}
Original file line number Diff line number Diff line change @@ -176,6 +176,17 @@ public class EvaluateTests: XCTestCase {
176
176
assertIfConfig ( " swift(>=5.5) " , . active)
177
177
assertIfConfig ( " swift(<6) " , . active)
178
178
assertIfConfig ( " swift(>=6) " , . unparsed)
179
+ assertIfConfig (
180
+ " swift(>=...) " ,
181
+ . unparsed,
182
+ diagnostics: [
183
+ DiagnosticSpec (
184
+ message: " 'swift' version check has invalid version '' " ,
185
+ line: 1 ,
186
+ column: 9
187
+ )
188
+ ]
189
+ )
179
190
assertIfConfig ( " compiler(>=5.8) " , . active)
180
191
assertIfConfig ( " compiler(>=5.9) " , . active)
181
192
assertIfConfig ( " compiler(>=5.10) " , . unparsed)
@@ -206,6 +217,17 @@ public class EvaluateTests: XCTestCase {
206
217
)
207
218
]
208
219
)
220
+ assertIfConfig (
221
+ #"_compiler_version("...")"# ,
222
+ . unparsed,
223
+ diagnostics: [
224
+ DiagnosticSpec (
225
+ message: " found empty version component " ,
226
+ line: 1 ,
227
+ column: 20
228
+ )
229
+ ]
230
+ )
209
231
}
210
232
211
233
func testCanImport( ) throws {
You can’t perform that action at this time.
0 commit comments