Hello everyone, I just installed Xcode 10.2 & the shiny new Swift 5
lldb-1001.0.12.1
Swift-5.0
... but this code crashed (only tried on command line):
extension Array {
func sort<T: Comparable>(_ sortProperties: KeyPath<Element, T>...) { }
}
var a = [1, 2, 3]
a.sort() // this is ok
a.sort(\.description) // 💥
The crash is the following:
Fatal error: load from misaligned raw pointer
2019-03-29 22:23:42.056529+0100 repl_swift[5079:831788] Fatal error: load from misaligned raw pointer
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
Process 5079 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x00007fff79ed9483 libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 307
libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never:
-> 0x7fff79ed9483 <+307>: ud2
0x7fff79ed9485 <+309>: movq %r12, %rdi
0x7fff79ed9488 <+312>: addq $0x10, %rdi
0x7fff79ed948c <+316>: cmpl $0x80, %r14d
And the backtrace is the following:
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x00007fff79ed9483 libswiftCore.dylib`function signature specialization <Arg[0] = Exploded, Arg[1] = Exploded, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 307
frame #1: 0x00007fff79dd791a libswiftCore.dylib`generic specialization <Swift.GetKeyPathClassAndInstanceSizeFromPattern> of Swift._walkKeyPathPattern<A where A: Swift.KeyPathPatternVisitor>(_: Swift.UnsafeRawPointer, walker: inout A) -> () + 1370
frame #2: 0x00007fff79dd6d34 libswiftCore.dylib`Swift._getKeyPathClassAndInstanceSizeFromPattern(Swift.UnsafeRawPointer, Swift.UnsafeRawPointer) -> (keyPathClass: Swift.AnyKeyPath.Type, rootType: Any.Type, size: Swift.Int, alignmentMask: Swift.Int) + 100
frame #3: 0x00007fff79dd6ae6 libswiftCore.dylib`Swift._swift_getKeyPath(pattern: Swift.UnsafeMutableRawPointer, arguments: Swift.UnsafeRawPointer) -> Swift.UnsafeRawPointer + 118
frame #4: 0x00007fff79dd6a69 libswiftCore.dylib`swift_getKeyPathImpl + 9
frame #5: 0x00000001000e5c8b $__lldb_expr14`main at repl.swift:9:8
frame #6: 0x0000000100000ea0 repl_swift`repl_swift.repl_main() -> Swift.Int + 16
frame #7: 0x00007fff7a55b3d5 libdyld.dylib`start + 1
frame #8: 0x00007fff7a55b3d5 libdyld.dylib`start + 1
What might be happening?