Hiya, I've upgraded the compiler to release/5.8 and rebased my changes on top. I'm getting errors compiling my standard library...
FixedWidth.swift:5:17: error: cannot build rewrite system for protocol; rule length limit exceeded
public protocol FixedWidthInteger : BinaryInteger
^
FixedWidth.swift:5:17: note: failed rewrite rule is [FixedWidthInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Magnitude].[FixedWidthInteger] => [FixedWidthInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Stride].[SignedInteger:Magnitude]
public protocol FixedWidthInteger : BinaryInteger
My standard library is more like a derivation of the swift 5.3 standard library, so I was expecting some friction with suddenly jumping forward a couple of years worth of compiler tech. I'm assuming the error comes from something like the new "Requirement Machine" (The "Requirement Machine", a new generics implementation based on term rewriting) ...but it's quite opaque to me what the actual problem might be, what swift is finding undecidable.
My core protocols around numerics and integers are pretty much unchanged from vanilla 5.3 (just some things like string conversions removed and some minor tweaks).
Here's an excerpt (edited to be as concise as possible) from my standard library...
public protocol Equatable {
static func == (lhs: Self, rhs: Self) -> Bool
}
public protocol Comparable : Equatable {
static func < (lhs: Self, rhs: Self) -> Bool
static func <= (lhs: Self, rhs: Self) -> Bool
static func >= (lhs: Self, rhs: Self) -> Bool
static func > (lhs: Self, rhs: Self) -> Bool
}
public protocol AdditiveArithmetic : Equatable {
static var zero: Self { get }
static func +=(lhs: inout Self, rhs: Self)
static func -(lhs: Self, rhs: Self) -> Self
static func -=(lhs: inout Self, rhs: Self)
static func +(lhs: Self, rhs: Self) -> Self
}
public protocol Numeric : AdditiveArithmetic, Comparable, ExpressibleByIntegerLiteral {
associatedtype Magnitude : Numeric
var magnitude: Magnitude { get }
static func *(lhs: Self, rhs: Self) -> Self
static func *=(lhs: inout Self, rhs: Self)
}
public protocol SignedNumeric : Numeric {
static prefix func - (_ operand: Self) -> Self
mutating func negate()
}
public protocol Strideable : Comparable {
associatedtype Stride : SignedNumeric
func distance(to other: Self) -> Stride
func advanced(by n: Stride) -> Self
static func _step(
after current: (index: Int?, value: Self),
from start: Self, by distance: Self.Stride
) -> (index: Int?, value: Self)
}
public protocol BinaryInteger : Numeric, Hashable, Strideable
where Magnitude : BinaryInteger, Magnitude.Magnitude == Magnitude
{
// init<T : BinaryFloatingPoint>(_ source: T)
init<T : BinaryInteger>(_ source: T)
init<T : BinaryInteger>(truncatingIfNeeded source: T)
static var isSigned: Bool { get }
var _lowWord: UInt { get }
var bitWidth: Int { get }
associatedtype Words : RandomAccessCollection
where Words.Element == UInt, Words.Index == Int
var words: Words { get }
...etc...
}
public protocol SignedInteger : BinaryInteger, SignedNumeric {}
public protocol UnsignedInteger : BinaryInteger {}
public protocol FixedWidthInteger : BinaryInteger
// , LosslessStringConvertible
where Magnitude : FixedWidthInteger & UnsignedInteger,
Stride : FixedWidthInteger & SignedInteger
{
static var bitWidth: Int { get }
static var max: Self { get }
static var min: Self { get }
init(_truncatingBits bits: UInt)
var nonzeroBitCount: Int { get }
var leadingZeroBitCount: Int { get }
...etc...
}
...when I look at the modern release/5.8 standard library, all these protocols look to be basically pretty much unchanged. So I'm wondering how the new compiler is getting upset by my simpler versions?
Can anyone offer insight or a path for how I can debug what the compiler is actually unhappy about? Where it can't decide and that's changed?
Thanks for any help or advice you can give!
Carl