Hi, I am building a variant, reduced and cut down standard library with a very slightly patched version of the compiler. Using c6b7b1f6b8668a517d753d2576282ab7d86ccf95
with [AVR] Fix IRGen function emission to respect LLVM DataLayout program address space. by carlos4242 · Pull Request #78810 · swiftlang/swift · GitHub added to fix AVR code emission.
I'm getting this slightly hard to decipher diagnostic, I wondered if anyone can help?...
UTF16.swift:91:23: error: type 'Encoding.Type' cannot conform to 'BinaryInteger' [#ProtocolTypeNonConformance]
89 |
90 | // Fast path for ASCII in a UTF8 buffer
91 | if sourceEncoding == Unicode.UTF8.self {
| |- error: type 'Encoding.Type' cannot conform to 'BinaryInteger' [#ProtocolTypeNonConformance]
| `- note: only concrete types such as structs, enums and classes can conform to protocols
92 | var peek: Encoding.CodeUnit = 0
93 | while let u = i.next() {
BinaryInteger.swift:269:1: note: required by referencing operator function '==' on 'BinaryInteger' where 'Self' = 'Encoding.Type'
267 | //===----------------------------------------------------------------------===//
268 |
269 | extension BinaryInteger {
| `- note: required by referencing operator function '==' on 'BinaryInteger' where 'Self' = 'Encoding.Type'
270 | @_transparent
271 | public static func == <
...the code in question is the same as the normal stdlib, rearranged into different files...
@inlinable
public static func transcodedLength<
Input : IteratorProtocol,
Encoding : Unicode.Encoding
>(
of input: Input,
decodedAs sourceEncoding: Encoding.Type,
repairingIllFormedSequences: Bool
) -> (count: Int, isASCII: Bool)?
where Encoding.CodeUnit == Input.Element {
var utf16Count: Int = 0
var i = input
var d = Encoding.ForwardParser()
// Fast path for ASCII in a UTF8 buffer
if sourceEncoding == Unicode.UTF8.self {
var peek: Encoding.CodeUnit = 0
while let u = i.next() {
peek = u
guard _fastPath(peek < 0x80) else { break }
utf16Count = utf16Count + 1
}
if _fastPath(peek < 0x80) { return (utf16Count, true) }
var d1 = UTF8.ForwardParser()
d1._buffer.append(numericCast(peek))
d = _identityCast(d1, to: Encoding.ForwardParser.self)
}
This is being compiled in embedded mode. I've checked and _UnicodeEncoding seems normal and is included in the compile.
The compile command is...
"/Users/carl/Documents/Code/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/bin/swiftc" -parse-as-library -parse-stdlib -target avr-none-none-elf -nostdimport -I uSwiftShims -I "/Applications/S4A IDE Pro.app/Contents/XPCServices/BuildEngine.xpc/Contents/Resources/lib/avr-libgcc/include" -I "/Applications/S4A IDE Pro.app/Contents/XPCServices/BuildEngine.xpc/Contents/Resources/lib/avr-libc/include" -Xcc -DAVR_LIBC_DEFINED -Xcc -DLIBC_DEFINED -DAVR_LIBC_DEFINED_SWIFT -DFORCE_MAIN_SWIFT_ARRAYS -enable-experimental-feature Embedded -Xfrontend -disable-reflection-metadata -Xfrontend -disable-stack-protector -Osize -whole-module-optimization -emit-module -emit-module-path bin/AVR-Embedded/Swift.swiftmodule -module-name Swift CoreOperators.swift CoreAliases.swift RawRepresentable.swift LiteralProtocols.swift TopLevelFunctions.swift CoreProtocols.swift CoreFloatingPoint.swift CoreBinaryFloatingPoint.swift Float.swift Float16.swift CoreFloatingPointFunctions.swift Optional.swift Bridging.swift CoreNumericProtocols.swift BinaryInteger.swift CoreIntegers.swift ErrorType.swift Bool.swift Integers.swift Ranges.swift Sequence.swift Stride.swift Slice.swift Collection.swift BidirectionalCollection.swift RandomAccessCollection.swift ClosedRange.swift MutableCollection.swift Hash.swift Pointer.swift UnsafeBufferPointer.swift UnsafeRawBufferPointer.swift UnsafeRawPointer.swift Indices.swift Existential.swift Algorithm.swift FixedWidth.swift IntegerMath.swift CTypes.swift UnsafePointer.swift ObjectIdentifier.swift CollectionAlgorithms.swift WriteBackMutableSlice.swift Random.swift RangeReplaceableCollection.swift MemoryLayout.swift Tuple.swift SequenceAlgorithms.swift LifetimeManager.swift Repeat.swift EmptyCollection.swift CollectionOfOne.swift StringLiterals.swift StaticString.swift StringInterpolation.swift Unicode.swift UnicodeScalar.swift UnicodeEncoding.swift UTF8.swift UTF16.swift ValidUTF8Buffer.swift UnicodeParser.swift UIntBuffer.swift UTFEncoding.swift UTF32.swift ArrayType.swift ArrayBufferProtocol.swift ArrayLiterals.swift ArrayShared.swift ContiguousArray.swift SliceBuffer.swift ArraySlice.swift Array.swift ArrayBody.swift ArrayCast.swift AnyHashable.swift ManagedBuffer.swift Reverse.swift Map.swift Zip.swift LazySequence.swift LazyCollection.swift Filter.swift FlatMap.swift Flatten.swift DropWhile.swift Volatile.swift uSwift.swift Identifiable.swift OptionSet.swift Sendable.swift SetAlgebra.swift Unmanaged.swift ContiguousArrayBuffer.swift Integer-16.swift IntegerMath-16.swift CTypes-16.swift Progmem.swift EmbeddedRuntime.swift version.swift
Can anyone suggest why the type checker is struggling here, when it works in the normal standard library?
Any help greatly appreciated!
Thanks,
Carl
@kubamracek thanks for your advice.