Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import Cocoa
func cons(x: Any, y: Any) -> (((Any, Any) -> Any) -> Any) {
return { (m: (Any, Any) -> Any) -> Any in
return m(x, y)
}
}
func car(z: (((Any, Any) -> Any) -> Any)) -> Any {
return z({ (p: Any, q:Any) -> Any in
return p
})
}
func cdr(z: (((Any, Any) -> Any) -> Any)) -> Any {
return z({ (p: Any, q:Any) -> Any in
return q
})
}
car(cons(1, 2))
cdr(cons(1, 2))
// car(cons(1, cons(2, 3))) // This line crashes XCode
0 swift 0x000000010f90c608 llvm::sys::PrintStackTrace(__sFILE*) + 40
1 swift 0x000000010f90caf4 SignalHandler(int) + 452
2 libsystem_platform.dylib 0x00007fff92bdf5aa _sigtramp + 26
3 libsystem_platform.dylib 0x00007f8759ebc510 _sigtramp + 3341668224
4 swift 0x000000010ed0a41c llvm::Value* swift::CanTypeVisitor<(anonymous namespace)::EmitTypeMetadataRef, llvm::Value*>::visit<>(swift::CanType) + 124
5 swift 0x000000010ed0aaf9 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::SILType) + 25
6 swift 0x000000010ed3c49b swift::irgen::emitOpaqueExistentialContainerInit(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::SILType, swift::SILType, llvm::ArrayRef<swift::ProtocolConformance*>) + 107
7 swift 0x000000010ed7a41f swift::SILVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::ValueBase*) + 35263
8 swift 0x000000010ed71266 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 8678
9 swift 0x000000010ecf2937 swift::irgen::IRGenModule::emitLazyDefinitions() + 199
10 swift 0x000000010ed5e786 performIRGeneration(swift::IRGenOptions&, swift::Module*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 2022
11 swift 0x000000010ed5df8a swift::performIRGeneration(swift::IRGenOptions&, swift::Module*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&) + 42
12 swift 0x000000010ee7e450 swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) + 128
13 swift 0x000000010ecd179f frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 5167
14 swift 0x000000010ecd035d main + 1533
15 libdyld.dylib 0x00007fff8af755fd start + 1
16 libdyld.dylib 0x000000000000000c start + 1963502096
Stack dump:
0. Program arguments: /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -i foo.swift -enable-objc-attr-requires-objc-module -target x86_64-apple-darwin13.2.0 -module-name foo -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -color-diagnostics
1. While emitting IR SIL function @top_level_codeSegmentation fault: 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment