Skip to content

Commit 0ebfed3

Browse files
committed
Enable resilience for _MatchingEngine and _StringProcessing.
_MatchingEngine and _StringProcessing are built with resilience enabled in Swift core libs. Currently the compiler build produces lots of warnings of missing `@unknown default`. We enable resilience in this package so that we can catch these issues early.
1 parent e6ec173 commit 0ebfed3

File tree

8 files changed

+26
-6
lines changed

8 files changed

+26
-6
lines changed

Package.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,19 @@ let package = Package(
3131
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
3232
.target(
3333
name: "_MatchingEngine",
34-
dependencies: [/*"_Unicode"*/]),
34+
dependencies: [/*"_Unicode"*/],
35+
swiftSettings: [
36+
.unsafeFlags(["-enable-library-evolution"])
37+
]),
3538
.testTarget(
3639
name: "MatchingEngineTests",
3740
dependencies: ["_MatchingEngine"]),
3841
.target(
3942
name: "_StringProcessing",
40-
dependencies: ["_MatchingEngine"]),
43+
dependencies: ["_MatchingEngine"],
44+
swiftSettings: [
45+
.unsafeFlags(["-enable-library-evolution"])
46+
]),
4147
.target(
4248
name: "_Unicode",
4349
dependencies: []),

Sources/_MatchingEngine/Regex/AST/AST.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// A regex abstract syntax tree
2+
@frozen
23
public indirect enum AST:
34
Hashable/*, _ASTPrintable ASTValue, ASTAction*/
45
{

Sources/_MatchingEngine/Regex/AST/Atom.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extension AST {
88
self.location = loc
99
}
1010

11+
@frozen
1112
public enum Kind: Hashable {
1213
/// Just a character
1314
///
@@ -68,6 +69,7 @@ extension AST.Atom {
6869

6970
// Characters, character types, literals, etc., derived from
7071
// an escape sequence.
72+
@frozen
7173
public enum EscapedBuiltin: Hashable {
7274
// TOOD: better doc comments
7375

@@ -320,6 +322,7 @@ extension AST.Atom {
320322
}
321323

322324
extension AST.Atom.CharacterProperty {
325+
@frozen
323326
public enum Kind: Hashable {
324327
/// Matches any character, equivalent to Oniguruma's '\O'.
325328
case any
@@ -358,6 +361,7 @@ extension AST.Atom.CharacterProperty {
358361
}
359362

360363
// TODO: erm, separate out or fold into something? splat it in?
364+
@frozen
361365
public enum PCRESpecialCategory: String, Hashable {
362366
case alphanumeric = "Xan"
363367
case posixSpace = "Xps"
@@ -371,6 +375,7 @@ extension AST.Atom.CharacterProperty {
371375
// TODO: I haven't thought through this a bunch; this seems like
372376
// a sensible type to have and break down this way. But it could
373377
// easily get folded in with the kind of reference
378+
@frozen
374379
public enum Reference: Hashable {
375380
// \n \gn \g{n} \g<n> \g'n' (?n) (?(n)...
376381
// Oniguruma: \k<n>, \k'n'
@@ -397,6 +402,7 @@ public enum Reference: Hashable {
397402

398403
extension AST.Atom {
399404
/// Anchors and other built-in zero-width assertions
405+
@frozen
400406
public enum AssertionKind: String {
401407
/// \A
402408
case startOfSubject = #"\A"#

Sources/_MatchingEngine/Regex/AST/CustomCharClass.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extension AST {
1616
self.location = sr
1717
}
1818

19+
@frozen
1920
public enum Member: Hashable {
2021
/// A nested custom character class `[[ab][cd]]`
2122
case custom(CustomCharacterClass)
@@ -40,14 +41,15 @@ extension AST {
4041
self.rhs = rhs
4142
}
4243
}
44+
@frozen
4345
public enum SetOp: String, Hashable {
4446
case subtraction = "--"
4547
case intersection = "&&"
4648
case symmetricDifference = "~~"
4749
}
50+
@frozen
4851
public enum Start: String {
4952
case normal = "["
50-
5153
case inverted = "[^"
5254
}
5355
}

Sources/_MatchingEngine/Regex/AST/Quantification.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ extension AST {
1818
self.location = r
1919
}
2020

21+
@frozen
2122
public enum Amount: Hashable {
2223
case zeroOrMore // *
2324
case oneOrMore // +
@@ -28,6 +29,7 @@ extension AST {
2829
case range(Located<Int>, Located<Int>) // {n,m}
2930
}
3031

32+
@frozen
3133
public enum Kind: String, Hashable {
3234
case eager = ""
3335
case reluctant = "?"

Sources/_MatchingEngine/Utility/MissingUnicode.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extension Unicode {
88
/// but is defined by https://www.unicode.org/Public/UCD/latest/ucd/PropertyValueAliases.txt.
99
/// We may want to split it out, as it's the only case that is a union of
1010
/// other script types.
11+
@frozen
1112
public enum Script: String, Hashable {
1213
case adlam = "Adlam"
1314
case ahom = "Ahom"
@@ -176,6 +177,7 @@ extension Unicode {
176177

177178
/// POSIX character properties not already covered by general categories or
178179
/// binary properties.
180+
@frozen
179181
public enum POSIXProperty: String, Hashable {
180182
case alnum = "alnum"
181183
case blank = "blank"
@@ -193,6 +195,7 @@ extension Unicode {
193195

194196
/// Unicode.GeneralCategory + cases for "meta categories" such as "L", which
195197
/// encompasses Lu | Ll | Lt | Lm | Lo.
198+
@frozen
196199
public enum ExtendedGeneralCategory: String, Hashable {
197200
case other = "C"
198201
case control = "Cc"
@@ -242,6 +245,7 @@ extension Unicode {
242245

243246
/// A list of unicode properties that can either be true or false.
244247
/// https://www.unicode.org/Public/UCD/latest/ucd/PropertyAliases.txt
248+
@frozen
245249
public enum BinaryProperty: String, Hashable {
246250
case asciiHexDigit = "ASCII_Hex_Digit"
247251
case alphabetic = "Alphabetic"
@@ -316,6 +320,7 @@ extension Unicode {
316320
/// Oniguruma properties that are not covered by Unicode spellings.
317321
/// TODO: These should become aliases for the Block (blk) Unicode character
318322
/// property.
323+
@frozen
319324
public enum OnigurumaSpecialProperty: String, Hashable {
320325
case inBasicLatin = "In_Basic_Latin"
321326
case inLatin1Supplement = "In_Latin_1_Supplement"

Sources/_StringProcessing/ConsumerInterface.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ extension AST {
3939
return try a.generateConsumer(opts)
4040
case .customCharacterClass(let ccc):
4141
return try ccc.generateConsumer(opts)
42-
4342
case .alternation, .concatenation, .group,
4443
.quantification, .quote, .trivia, .empty,
4544
.groupTransform: return nil
@@ -513,9 +512,9 @@ extension Unicode.POSIXProperty {
513512

514513
case .xdigit:
515514
return consumeScalarProp(\.isHexDigit) // or number
515+
516516
}
517517
}
518-
519518
}
520519

521520
extension Unicode.ExtendedGeneralCategory {

Sources/_StringProcessing/Legacy/LegacyCompile.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ func compile(
252252
case .atom(let a) where a.characterClass != nil:
253253
fatalError("unreachable")
254254
}
255-
256255
}
257256

258257
try compileNode(ast)

0 commit comments

Comments
 (0)