Skip to content

Commit 2e3558d

Browse files
authored
Use swift:6.2-noble container image in format.yml (#200)
This ensures we use the latest released version of `swift-format`.
1 parent ccbdb53 commit 2e3558d

File tree

36 files changed

+179
-167
lines changed

36 files changed

+179
-167
lines changed

.github/workflows/format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
group: ${{ github.workflow }}-${{ github.ref }}
1010
cancel-in-progress: true
1111
container:
12-
image: swift:6.0.1-jammy
12+
image: swift:6.2-noble
1313
steps:
1414
- uses: actions/checkout@v4
15-
- run: ./Utilities/format.py
15+
- run: apt-get update && apt-get install -y python3 && ./Utilities/format.py
1616
- name: Check for formatting changes
1717
run: |
1818
git config --global --add safe.directory "$GITHUB_WORKSPACE"

Sources/WASI/WASI.swift

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ public class WASIBridgeToHost: WASI {
14941494
}
14951495

14961496
func fd_advise(fd: WASIAbi.Fd, offset: WASIAbi.FileSize, length: WASIAbi.FileSize, advice: WASIAbi.Advice) throws {
1497-
guard case let .file(fileEntry) = fdTable[fd] else {
1497+
guard case .file(let fileEntry) = fdTable[fd] else {
14981498
throw WASIAbi.Errno.EBADF
14991499
}
15001500
try fileEntry.advise(offset: offset, length: length, advice: advice)
@@ -1518,7 +1518,7 @@ public class WASIBridgeToHost: WASI {
15181518
}
15191519

15201520
func fd_datasync(fd: WASIAbi.Fd) throws {
1521-
guard case let .file(fileEntry) = fdTable[fd] else {
1521+
guard case .file(let fileEntry) = fdTable[fd] else {
15221522
throw WASIAbi.Errno.EBADF
15231523
}
15241524
return try fileEntry.datasync()
@@ -1527,7 +1527,7 @@ public class WASIBridgeToHost: WASI {
15271527
func fd_fdstat_get(fileDescriptor: UInt32) throws -> WASIAbi.FdStat {
15281528
let entry = self.fdTable[fileDescriptor]
15291529
switch entry {
1530-
case let .file(entry):
1530+
case .file(let entry):
15311531
return try entry.fdStat()
15321532
case .directory:
15331533
return WASIAbi.FdStat(
@@ -1542,7 +1542,7 @@ public class WASIBridgeToHost: WASI {
15421542
}
15431543

15441544
func fd_fdstat_set_flags(fd: WASIAbi.Fd, flags: WASIAbi.Fdflags) throws {
1545-
guard case let .file(fileEntry) = fdTable[fd] else {
1545+
guard case .file(let fileEntry) = fdTable[fd] else {
15461546
throw WASIAbi.Errno.EBADF
15471547
}
15481548
try fileEntry.setFdStatFlags(flags)
@@ -1564,7 +1564,7 @@ public class WASIBridgeToHost: WASI {
15641564
}
15651565

15661566
func fd_filestat_set_size(fd: WASIAbi.Fd, size: WASIAbi.FileSize) throws {
1567-
guard case let .file(entry) = fdTable[fd] else {
1567+
guard case .file(let entry) = fdTable[fd] else {
15681568
throw WASIAbi.Errno.EBADF
15691569
}
15701570
return try entry.setFilestatSize(size)
@@ -1584,14 +1584,14 @@ public class WASIBridgeToHost: WASI {
15841584
fd: WASIAbi.Fd, iovs: UnsafeGuestBufferPointer<WASIAbi.IOVec>,
15851585
offset: WASIAbi.FileSize
15861586
) throws -> WASIAbi.Size {
1587-
guard case let .file(fileEntry) = fdTable[fd] else {
1587+
guard case .file(let fileEntry) = fdTable[fd] else {
15881588
throw WASIAbi.Errno.EBADF
15891589
}
15901590
return try fileEntry.pread(into: iovs, offset: offset)
15911591
}
15921592

15931593
func fd_prestat_get(fd: WASIAbi.Fd) throws -> WASIAbi.Prestat {
1594-
guard case let .directory(entry) = fdTable[fd],
1594+
guard case .directory(let entry) = fdTable[fd],
15951595
let preopenPath = entry.preopenPath
15961596
else {
15971597
throw WASIAbi.Errno.EBADF
@@ -1600,7 +1600,7 @@ public class WASIBridgeToHost: WASI {
16001600
}
16011601

16021602
func fd_prestat_dir_name(fd: WASIAbi.Fd, path: UnsafeGuestPointer<UInt8>, maxPathLength: WASIAbi.Size) throws {
1603-
guard case let .directory(entry) = fdTable[fd],
1603+
guard case .directory(let entry) = fdTable[fd],
16041604
var preopenPath = entry.preopenPath
16051605
else {
16061606
throw WASIAbi.Errno.EBADF
@@ -1620,7 +1620,7 @@ public class WASIBridgeToHost: WASI {
16201620
fd: WASIAbi.Fd, iovs: UnsafeGuestBufferPointer<WASIAbi.IOVec>,
16211621
offset: WASIAbi.FileSize
16221622
) throws -> WASIAbi.Size {
1623-
guard case let .file(fileEntry) = fdTable[fd] else {
1623+
guard case .file(let fileEntry) = fdTable[fd] else {
16241624
throw WASIAbi.Errno.EBADF
16251625
}
16261626
return try fileEntry.pwrite(vectored: iovs, offset: offset)
@@ -1630,7 +1630,7 @@ public class WASIBridgeToHost: WASI {
16301630
fd: WASIAbi.Fd,
16311631
iovs: UnsafeGuestBufferPointer<WASIAbi.IOVec>
16321632
) throws -> WASIAbi.Size {
1633-
guard case let .file(fileEntry) = fdTable[fd] else {
1633+
guard case .file(let fileEntry) = fdTable[fd] else {
16341634
throw WASIAbi.Errno.EBADF
16351635
}
16361636
return try fileEntry.read(into: iovs)
@@ -1641,7 +1641,7 @@ public class WASIBridgeToHost: WASI {
16411641
buffer: UnsafeGuestBufferPointer<UInt8>,
16421642
cookie: WASIAbi.DirCookie
16431643
) throws -> WASIAbi.Size {
1644-
guard case let .directory(dirEntry) = fdTable[fd] else {
1644+
guard case .directory(let dirEntry) = fdTable[fd] else {
16451645
throw WASIAbi.Errno.EBADF
16461646
}
16471647

@@ -1693,21 +1693,21 @@ public class WASIBridgeToHost: WASI {
16931693
}
16941694

16951695
func fd_seek(fd: WASIAbi.Fd, offset: WASIAbi.FileDelta, whence: WASIAbi.Whence) throws -> WASIAbi.FileSize {
1696-
guard case let .file(fileEntry) = fdTable[fd] else {
1696+
guard case .file(let fileEntry) = fdTable[fd] else {
16971697
throw WASIAbi.Errno.EBADF
16981698
}
16991699
return try fileEntry.seek(offset: offset, whence: whence)
17001700
}
17011701

17021702
func fd_sync(fd: WASIAbi.Fd) throws {
1703-
guard case let .file(fileEntry) = fdTable[fd] else {
1703+
guard case .file(let fileEntry) = fdTable[fd] else {
17041704
throw WASIAbi.Errno.EBADF
17051705
}
17061706
return try fileEntry.sync()
17071707
}
17081708

17091709
func fd_tell(fd: WASIAbi.Fd) throws -> WASIAbi.FileSize {
1710-
guard case let .file(fileEntry) = fdTable[fd] else {
1710+
guard case .file(let fileEntry) = fdTable[fd] else {
17111711
throw WASIAbi.Errno.EBADF
17121712
}
17131713
return try fileEntry.tell()
@@ -1717,14 +1717,14 @@ public class WASIBridgeToHost: WASI {
17171717
fileDescriptor: WASIAbi.Fd,
17181718
ioVectors: UnsafeGuestBufferPointer<WASIAbi.IOVec>
17191719
) throws -> UInt32 {
1720-
guard case let .file(entry) = self.fdTable[fileDescriptor] else {
1720+
guard case .file(let entry) = self.fdTable[fileDescriptor] else {
17211721
throw WASIAbi.Errno.EBADF
17221722
}
17231723
return try entry.write(vectored: ioVectors)
17241724
}
17251725

17261726
func path_create_directory(dirFd: WASIAbi.Fd, path: String) throws {
1727-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1727+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
17281728
throw WASIAbi.Errno.ENOTDIR
17291729
}
17301730
try dirEntry.createDirectory(atPath: path)
@@ -1733,7 +1733,7 @@ public class WASIBridgeToHost: WASI {
17331733
func path_filestat_get(
17341734
dirFd: WASIAbi.Fd, flags: WASIAbi.LookupFlags, path: String
17351735
) throws -> WASIAbi.Filestat {
1736-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1736+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
17371737
throw WASIAbi.Errno.ENOTDIR
17381738
}
17391739
return try dirEntry.attributes(
@@ -1746,7 +1746,7 @@ public class WASIBridgeToHost: WASI {
17461746
path: String, atim: WASIAbi.Timestamp, mtim: WASIAbi.Timestamp,
17471747
fstFlags: WASIAbi.FstFlags
17481748
) throws {
1749-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1749+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
17501750
throw WASIAbi.Errno.ENOTDIR
17511751
}
17521752
try dirEntry.setFilestatTimes(
@@ -1775,7 +1775,7 @@ public class WASIBridgeToHost: WASI {
17751775
#if os(Windows)
17761776
throw WASIAbi.Errno.ENOTSUP
17771777
#else
1778-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1778+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
17791779
throw WASIAbi.Errno.ENOTDIR
17801780
}
17811781
var accessMode: FileAccessMode = []
@@ -1814,7 +1814,7 @@ public class WASIBridgeToHost: WASI {
18141814
}
18151815

18161816
func path_remove_directory(dirFd: WASIAbi.Fd, path: String) throws {
1817-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1817+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
18181818
throw WASIAbi.Errno.ENOTDIR
18191819
}
18201820
try dirEntry.removeDirectory(atPath: path)
@@ -1824,24 +1824,24 @@ public class WASIBridgeToHost: WASI {
18241824
oldFd: WASIAbi.Fd, oldPath: String,
18251825
newFd: WASIAbi.Fd, newPath: String
18261826
) throws {
1827-
guard case let .directory(oldDirEntry) = fdTable[oldFd] else {
1827+
guard case .directory(let oldDirEntry) = fdTable[oldFd] else {
18281828
throw WASIAbi.Errno.ENOTDIR
18291829
}
1830-
guard case let .directory(newDirEntry) = fdTable[newFd] else {
1830+
guard case .directory(let newDirEntry) = fdTable[newFd] else {
18311831
throw WASIAbi.Errno.ENOTDIR
18321832
}
18331833
try oldDirEntry.rename(from: oldPath, toDir: newDirEntry, to: newPath)
18341834
}
18351835

18361836
func path_symlink(oldPath: String, dirFd: WASIAbi.Fd, newPath: String) throws {
1837-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1837+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
18381838
throw WASIAbi.Errno.ENOTDIR
18391839
}
18401840
try dirEntry.symlink(from: oldPath, to: newPath)
18411841
}
18421842

18431843
func path_unlink_file(dirFd: WASIAbi.Fd, path: String) throws {
1844-
guard case let .directory(dirEntry) = fdTable[dirFd] else {
1844+
guard case .directory(let dirEntry) = fdTable[dirFd] else {
18451845
throw WASIAbi.Errno.ENOTDIR
18461846
}
18471847
try dirEntry.removeFile(atPath: path)

Sources/WAT/Encoder.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ extension WAT.WatParser.ElementDecl {
244244
if let tableIndex = tableIndex {
245245
encoder.writeUnsignedLEB128(tableIndex)
246246
}
247-
if case let .active(_, offset) = self.mode {
247+
if case .active(_, let offset) = self.mode {
248248
switch offset {
249249
case .expression(var lexer):
250250
try encoder.writeExpression(lexer: &lexer, wat: &wat)
@@ -288,7 +288,7 @@ extension WAT.WatParser.ElementDecl {
288288
}
289289
} else {
290290
encoder.encodeVector(collector.instructions) { instruction, encoder in
291-
guard case let .refFunc(funcIndex) = instruction else { fatalError("non-ref.func instruction in non-expression mode") }
291+
guard case .refFunc(let funcIndex) = instruction else { fatalError("non-ref.func instruction in non-expression mode") }
292292
encoder.writeUnsignedLEB128(funcIndex)
293293
}
294294
}
@@ -325,7 +325,7 @@ extension Export: WasmEncodable {
325325
extension WatParser.GlobalDecl {
326326
func encode(to encoder: inout Encoder, wat: inout Wat) throws {
327327
encoder.encode(type)
328-
guard case var .definition(expr) = kind else {
328+
guard case .definition(var expr) = kind else {
329329
fatalError("imported global declaration should not be encoded here")
330330
}
331331
try encoder.writeExpression(lexer: &expr, wat: &wat)
@@ -539,7 +539,7 @@ func encode(module: inout Wat, options: EncodeOptions) throws -> [UInt8] {
539539

540540
var codeEncoder = Encoder()
541541
let functions = module.functionsMap.compactMap { (function: WatParser.FunctionDecl) -> ([WatParser.LocalDecl], WatParser.FunctionDecl)? in
542-
guard case let .definition(locals, _) = function.kind else {
542+
guard case .definition(let locals, _) = function.kind else {
543543
return nil
544544
}
545545
return (locals, function)

Sources/WAT/NameMapping.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ struct TypesMap {
169169
/// Resolves a block type from a type use
170170
mutating func resolveBlockType(use: WatParser.TypeUse) throws -> BlockType {
171171
switch (use.index, use.inline) {
172-
case let (indexOrId?, inline):
172+
case (let indexOrId?, let inline):
173173
let (type, index) = try resolveAndCheck(use: indexOrId, inline: inline)
174174
return try resolveBlockType(signature: type.signature, resolveSignatureIndex: { _ in index })
175175
case (nil, let inline?):
@@ -180,7 +180,7 @@ struct TypesMap {
180180

181181
mutating func resolveIndex(use: WatParser.TypeUse) throws -> Int {
182182
switch (use.index, use.inline) {
183-
case let (indexOrId?, _):
183+
case (let indexOrId?, _):
184184
return try nameMapping.resolveIndex(use: indexOrId)
185185
case (nil, let inline):
186186
let inline = inline?.signature ?? WasmTypes.FunctionType(parameters: [], results: [])
@@ -208,7 +208,7 @@ struct TypesMap {
208208
/// Resolves a function type from a type use with an optional inline type
209209
mutating func resolve(use: WatParser.TypeUse) throws -> (type: WatParser.FunctionType, index: Int) {
210210
switch (use.index, use.inline) {
211-
case let (indexOrId?, inline):
211+
case (let indexOrId?, let inline):
212212
return try resolveAndCheck(use: indexOrId, inline: inline)
213213
case (nil, let inline):
214214
// If no index and no inline type, then it's a function type with no parameters or results

Sources/WAT/Parser.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ internal struct Parser {
5353

5454
mutating func takeUnsignedInt<IntegerType: UnsignedInteger & FixedWidthInteger>(_: IntegerType.Type = IntegerType.self) throws -> IntegerType? {
5555
guard let token = try peek() else { return nil }
56-
guard case let .integer(nil, pattern) = token.kind else {
56+
guard case .integer(nil, let pattern) = token.kind else {
5757
return nil
5858
}
5959
try consume()
@@ -75,7 +75,7 @@ internal struct Parser {
7575
fromBitPattern: (UnsignedType) -> IntegerType
7676
) throws -> IntegerType? {
7777
guard let token = try peek() else { return nil }
78-
guard case let .integer(sign, pattern) = token.kind else {
78+
guard case .integer(let sign, let pattern) = token.kind else {
7979
return nil
8080
}
8181
try consume()
@@ -213,7 +213,7 @@ internal struct Parser {
213213
return value
214214
}
215215
switch token.kind {
216-
case let .float(sign, pattern):
216+
case .float(let sign, let pattern):
217217
let float: F
218218
switch pattern {
219219
case .decimalPattern(let pattern):
@@ -232,7 +232,7 @@ internal struct Parser {
232232
return bitPattern
233233
}
234234
return toBitPattern(sign == .minus ? -float : float)
235-
case let .integer(sign, pattern):
235+
case .integer(let sign, let pattern):
236236
let float: F
237237
switch pattern {
238238
case .hexPattern(let pattern):

Sources/WAT/Parser/WatParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct WatParser {
8181
///
8282
/// - Returns: Type index of this function
8383
func parse<V: InstructionVisitor>(visitor: inout V, wat: inout Wat, features: WasmFeatureSet) throws -> Int {
84-
guard case let .definition(locals, body) = kind else {
84+
guard case .definition(let locals, let body) = kind else {
8585
fatalError("Imported functions cannot be parsed")
8686
}
8787
let (type, typeIndex) = try wat.types.resolve(use: typeUse)

Sources/WAT/WAT.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ func parseWAT(_ parser: inout Parser, features: WasmFeatureSet) throws -> Wat {
219219
}
220220

221221
switch decl.kind {
222-
case let .type(decl):
222+
case .type(let decl):
223223
try typesMap.add(decl)
224-
case let .function(decl):
224+
case .function(let decl):
225225
try checkImportOrder(decl.importNames)
226226
let index = try functionsMap.add(decl)
227227
addExports(decl.exports, index: index, kind: .function)
@@ -233,7 +233,7 @@ func parseWAT(_ parser: inout Parser, features: WasmFeatureSet) throws -> Wat {
233233
return .function(TypeIndex(typeIndex))
234234
}
235235
}
236-
case let .table(decl):
236+
case .table(let decl):
237237
try checkImportOrder(decl.importNames)
238238
let index = try tablesMap.add(decl)
239239
addExports(decl.exports, index: index, kind: .table)
@@ -246,7 +246,7 @@ func parseWAT(_ parser: inout Parser, features: WasmFeatureSet) throws -> Wat {
246246
if let importNames = decl.importNames {
247247
addImport(importNames) { .table(decl.type) }
248248
}
249-
case let .memory(decl):
249+
case .memory(let decl):
250250
try checkImportOrder(decl.importNames)
251251
let index = try memoriesMap.add(decl)
252252
if var inlineData = decl.inlineData {
@@ -259,7 +259,7 @@ func parseWAT(_ parser: inout Parser, features: WasmFeatureSet) throws -> Wat {
259259
if let importNames = decl.importNames {
260260
addImport(importNames) { .memory(decl.type) }
261261
}
262-
case let .global(decl):
262+
case .global(let decl):
263263
try checkImportOrder(decl.importNames)
264264
let index = try globalsMap.add(decl)
265265
addExports(decl.exports, index: index, kind: .global)
@@ -268,13 +268,13 @@ func parseWAT(_ parser: inout Parser, features: WasmFeatureSet) throws -> Wat {
268268
case .imported(let importNames):
269269
addImport(importNames) { .global(decl.type) }
270270
}
271-
case let .element(decl):
271+
case .element(let decl):
272272
try elementSegmentsMap.add(decl)
273-
case let .export(decl):
273+
case .export(let decl):
274274
exportDecls.append(decl)
275-
case let .data(decl):
275+
case .data(let decl):
276276
try dataSegmentsMap.add(decl)
277-
case let .start(startIndex):
277+
case .start(let startIndex):
278278
guard start == nil else {
279279
throw WatParserError("Multiple start sections", location: location)
280280
}

0 commit comments

Comments
 (0)