-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
SILGenArea → compiler: The SIL generation stageArea → compiler: The SIL generation stageassertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsFeature: expressionsfunction typesFeature → types: function typesFeature → types: function typesgenericsFeature: generic declarations and typesFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsswift 6.0typesFeature: typesFeature: types
Description
Description
I'm trying to use parameter packs to create a function that takes and arbitrary function as a parameter. It's possible to create that function, but it's not possible to call it with a function or closure that has any parameters. Doing so causes the compiler to crash.
Stack trace passing a function with a parameter:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/fnord/Documents/Swift/TestMacOS/TestMacOSCore/Sources/TestMacOSCore/Dependencies.swift -primary-file /Users/fnord/Documents/Swift/TestMacOS/TestMacOSCore/Sources/TestMacOSCore/TestMacOSCore.swift -emit-dependencies-path /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore.d -emit-const-values-path /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore.swiftconstvalues -emit-reference-dependencies-path /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore.swiftdeps -serialize-diagnostics-path /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore.dia -target arm64-apple-macos14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -I /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug/PackageFrameworks -F /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug/PackageFrameworks -F /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug/PackageFrameworks -F /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug/PackageFrameworks -F /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug/PackageFrameworks -F /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -no-color-diagnostics -enable-testing -g -module-cache-path /Users/fnord/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -profile-generate -profile-coverage-mapping -swift-version 5 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -package-name testmacoscore -const-gather-protocols-file /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore_const_extract_protocols.json -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/fnord/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/fnord/Documents/Swift/TestMacOS/TestMacOSCore -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -ivfsstatcache -Xcc /Users/fnord/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx14.0-23A334-4a76ee93ef69e462914ffe9883de22b8.sdkstatcache -Xcc -I/Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/swift-overrides.hmap -Xcc -I/Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Products/Debug/include -Xcc -I/Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/DerivedSources-normal/arm64 -Xcc -I/Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/DerivedSources/arm64 -Xcc -I/Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name TestMacOSCore -frontend-parseable-output -disable-clang-spi -target-sdk-version 14.0 -target-sdk-name macosx14.0 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Build/Intermediates.noindex/TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore.o -index-unit-output-path /TestMacOSCore.build/Debug/TestMacOSCore.build/Objects-normal/arm64/TestMacOSCore.o -index-store-path /Users/fnord/Library/Developer/Xcode/DerivedData/TestMacOSCore-ahgngaarecknxsfwsewfijgzqaot/Index.noindex/DataStore -index-system-modules
1. Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
2. Compiling with the current language version
3. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Mandatory Diagnostic Passes + Enabling Optimization Passes } on SIL for TestMacOSCore)
4. While running pass #20 SILModuleTransform "DiagnoseStaticExclusivity".
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x0000000107ac314c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x000000010a641f2c llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x000000010638310c SignalHandler(int) + 352
3 libsystem_platform.dylib 0x0000000184841a24 _sigtramp + 56
4 swift-frontend 0x000000010987d8c4 checkForViolationAtApply(swift::ApplySite, (anonymous namespace)::AccessState&) + 544
5 swift-frontend 0x000000010987d8c4 checkForViolationAtApply(swift::ApplySite, (anonymous namespace)::AccessState&) + 544
6 swift-frontend 0x000000010986f1d8 (anonymous namespace)::DiagnoseStaticExclusivity::run() (.llvm.4864455472777275936) + 2220
7 swift-frontend 0x0000000109f9b08c swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16276
8 swift-frontend 0x000000010a11ef90 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56
9 swift-frontend 0x0000000109fd47e4 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476
10 swift-frontend 0x0000000109fef728 swift::runSILDiagnosticPasses(swift::SILModule&) + 380
11 swift-frontend 0x0000000105a99f58 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 72
12 swift-frontend 0x0000000109ed7328 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 956
13 swift-frontend 0x000000010a5f991c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1748
14 swift-frontend 0x000000010a5fd474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
15 swift-frontend 0x0000000109f434e0 swift::mainEntry(int, char const**) + 4116
16 dyld 0x0000000184499058 start + 2224
Steps to reproduce
This builds
func catFact() -> String { "there are more than 10 cats" }
func callable<each Input, Output>(wrappedValue: @escaping ((repeat each Input)) -> Output) {
}
func doSomething() {
callable(wrappedValue: catFact)
}This builds
func callable<each Input, Output>(wrappedValue: @escaping ((repeat each Input)) -> Output) {
}
func doSomething() {
callable(wrappedValue: {})
}This does not build
func catFact(num: Int) -> String { "there are more than 10 cats" }
func callable<each Input, Output>(wrappedValue: @escaping ((repeat each Input)) -> Output) {
}
func doSomething() {
callable(wrappedValue: catFact)
}This does not build
func callable<each Input, Output>(wrappedValue: @escaping ((repeat each Input)) -> Output) {
}
func doSomething() {
callable(wrappedValue: { (num: Int) in num })
}Expected behavior
I would expect each of the above examples to build successfully.
Environment
- Swift compiler version info:
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
- Xcode version info
Xcode 15.0
Build version 15A240d
-
Deployment target: macOS 14.0
-
Additional context: Development is being done in a Swift Package using Xcode.
Metadata
Metadata
Assignees
Labels
SILGenArea → compiler: The SIL generation stageArea → compiler: The SIL generation stageassertion failureBug → crash: An assertion failureBug → crash: An assertion failurebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsFeature → expressions: Call expressionscompilerThe Swift compiler itselfThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwareexpressionsFeature: expressionsFeature: expressionsfunction typesFeature → types: function typesFeature → types: function typesgenericsFeature: generic declarations and typesFeature: generic declarations and typesparameter packsFeature → generics: Parameter packsFeature → generics: Parameter packsswift 6.0typesFeature: typesFeature: types