Running: swiftformat file.swift --swiftversion 5.9 on this:
private enum Format {
case uint8
case uint16
var bytes: Int {
{
switch self {
case .uint8: return UInt8.bitWidth
case .uint16: return UInt16.bitWidth
}
}() / 8
}
}
gives this:
private enum Format {
case uint8
case uint16
var bytes: Int {
switch self {
case .uint8: UInt8.bitWidth
case .uint16: UInt16.bitWidth
} / 8
}
}
which doesn't compile:
file.swift:9:10: error: consecutive statements on a line must be separated by ';'
} / 8
^
;
file.swift:9:11: error: unary operator cannot be separated from its operand
} / 8
^~
file.swift:7:28: warning: expression of type 'Int' is unused
case .uint8: UInt8.bitWidth
~~~~~~^~~~~~~~
file.swift:8:30: warning: expression of type 'Int' is unused
case .uint16: UInt16.bitWidth
~~~~~~~^~~~~~~~
file.swift:9:11: error: '/' is not a prefix unary operator
} / 8
^
Swiftformat: 0.52.6
Running:
swiftformat file.swift --swiftversion 5.9
on this:gives this:
which doesn't compile: