Trying to use the new RandomNumberGenerator protocol

That protocol has this requirement:

mutating func next() -> UInt64

It also has this method in an extension, that calls that requirement:

mutating func next<T: FixedWidthInteger & UnsignedInteger>() -> T

Unfortunately for compiler diagnostics, that generic version satisfies the actual requirement, but when you call it you get infinite recursion. Perhaps we should add a default implementation of the requirement with a fatalError("You must implement the 'next() -> UInt64' requirement") message so that you get some help when you run into this.

5 Likes