A generic struct containing an optional protocol property and a closure crashes the compiler

Originator:mprudhom
Number:rdar://19297122 Date Originated:18-Dec-2014
Status:Open Resolved:
Product: Product Version:
Classification: Reproducible:
 
Summary:
When I create a struct with a generic parameter, a property that is an Optional<Printable> and a property that is a (T)->(Void), the compiler crashes when I try to access the second property.

Steps to Reproduce:
1. Make a text file called Foo.swift with the following code:

public struct ClosureHolder<T> {
  public let mode: Printable? = nil
  public let closure: (T)->(Void) = { _ in return }
}

func testClosureAccess() {
  let holder = ClosureHolder<Void>()
  holder.closure() // crashes the compiler
}

2. Compile the program with "swift Foo.swift"


Expected Results:
Program should compile

Actual Results:
21 swift                    0x0000000109ee2a01 swift::SILModule::constructSIL(swift::Module*, swift::SourceFile*, swift::Optional<unsigned int>) + 401
22 swift                    0x0000000109ee2a98 swift::performSILGeneration(swift::Module*) + 24
23 swift                    0x0000000109db8f9e frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 3566
24 swift                    0x0000000109db6a6d main + 1677
25 libdyld.dylib            0x00007fff89ec75c9 start + 1
26 libdyld.dylib            0x000000000000000c start + 1980992068
Stack dump:
0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret foo.swift -target x86_64-apple-darwin14.0.0 -target-cpu core2 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -module-name foo 
1.	While emitting SIL for 'testClosureAccess' at foo.swift:6:1


Version:
10.10

Notes:


Configuration:
Swift version 1.1 (swift-600.0.56.1)
Target: x86_64-apple-darwin14.0.0
/Applications/Xcode.app/Contents/Developer/usr/bin/lldb "--repl=-target x86_64-apple-darwin14.0.0 -target-cpu core2 -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -color-diagnostics"


Attachments:
'crash.log' was successfully uploaded.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!