Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variadic generics cause crash in UsePrespecialized pass #73660

Open
JadenGeller opened this issue May 16, 2024 · 1 comment
Open

Variadic generics cause crash in UsePrespecialized pass #73660

JadenGeller opened this issue May 16, 2024 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. closures Feature: closures compiler The Swift compiler in itself generics Feature: generic declarations and types implicit conversions Feature: implicit conversions swift 6.0 tuples Feature: tuples type checker Area → compiler: Semantic analysis types Feature: types unexpected error Bug: Unexpected error variadic generics Feature → generics: Variadic generics

Comments

@JadenGeller
Copy link
Contributor

JadenGeller commented May 16, 2024

Reproduction

struct Transformer<T, each V> {
    var transform: (repeat (T) -> each V)
}

let x = Transformer<String, (Int, Int)>(transform: { x in
    (x.count, x.count)
})

Stack dump

error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file "Untitled 11.swift" -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name main -disable-clang-spi -target-sdk-version 14.2 -target-sdk-name macosx14.2 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.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 "/var/folders/z7/v1gmxzg94ys8g2tdh5kdfhpm0000gn/T/TemporaryDirectory.4scSoy/Untitled 11-1.o"
1.	Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
2.	Compiling with the current language version
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { Non-Diagnostic Mandatory Optimizations, Serialization, Rest of Onone } on SIL for main)
4.	While running pass #37 SILModuleTransform "UsePrespecialized".
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           0x0000000102fb9abc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105c1fcb0 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105989054 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x0000000197133584 _sigtramp + 56
4  swift-frontend           0x0000000103294024 swift::FunctionType::get(llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::Type, llvm::Optional<swift::ASTExtInfo>) + 388
5  swift-frontend           0x0000000103d928ac (anonymous namespace)::SubstFunctionTypePatternVisitor::handleUnabstractedFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern) + 408
6  swift-frontend           0x00000001021eee50 swift::Lowering::AbstractionPattern::getSubstFunctionTypePattern(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeConverter&, swift::Lowering::AbstractionPattern, swift::CanType, bool&) const + 236
7  swift-frontend           0x0000000103f05414 getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 1988
8  swift-frontend           0x0000000103ef1890 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) (.llvm.13406110992970554804) + 2028
9  swift-frontend           0x00000001023d0350 swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor::visitAnyFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>) + 812
10 swift-frontend           0x0000000102397c34 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 556
11 swift-frontend           0x000000010237bfc0 swift::SILType::getFieldType(swift::VarDecl*, swift::Lowering::TypeConverter&, swift::TypeExpansionContext) const + 532
12 swift-frontend           0x000000010239fa30 countNumberOfInnerFields(unsigned int&, swift::Lowering::TypeConverter&, swift::SILType, swift::TypeExpansionContext) (.llvm.7070909980393714814) + 304
13 swift-frontend           0x000000010432b980 swift::Lowering::TypeConverter::countNumberOfFields(swift::SILType, swift::TypeExpansionContext) + 140
14 swift-frontend           0x0000000101df49cc swift::shouldExpand(swift::SILModule&, swift::SILType) + 544
15 swift-frontend           0x0000000101c6123c swift::ReabstractionInfo::getReturnTypeCategory(swift::SILResultInfo const&, swift::SILFunctionConventions const&, swift::TypeExpansionContext) + 728
16 swift-frontend           0x0000000101c54268 swift::ReabstractionInfo::createSubstitutedAndSpecializedTypes() + 956
17 swift-frontend           0x0000000103454c84 swift::ReabstractionInfo::ReabstractionInfo(swift::ModuleDecl*, bool, swift::ApplySite, swift::SILFunction*, swift::SubstitutionMap, swift::IsSerialized_t, bool, bool, swift::OptRemark::Emitter*) + 312
18 swift-frontend           0x00000001047f2ad8 (anonymous namespace)::UsePrespecialized::run() (.llvm.8694276049873696124) + 1020
19 swift-frontend           0x00000001055c0874 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 16276
20 swift-frontend           0x000000010576a1c4 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 56
21 swift-frontend           0x000000010560c6b8 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 476
22 swift-frontend           0x0000000105625ce8 swift::runSILPassesForOnone(swift::SILModule&) + 184
23 swift-frontend           0x00000001035b43b4 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 560
24 swift-frontend           0x0000000105501454 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
25 swift-frontend           0x00000001054fca08 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1748
26 swift-frontend           0x0000000105500854 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
27 swift-frontend           0x0000000105567d44 swift::mainEntry(int, char const**) + 4408
28 dyld                     0x0000000196d7a0e0 start + 2360
error: fatalError

Expected behavior

It should compile.

Environment

swift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0

Additional information

No response

@JadenGeller JadenGeller added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels May 16, 2024
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis generics Feature: generic declarations and types tuples Feature: tuples unexpected error Bug: Unexpected error variadic generics Feature → generics: Variadic generics implicit conversions Feature: implicit conversions swift 6.0 types Feature: types closures Feature: closures and removed crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels May 17, 2024
@AnthonyLatsis
Copy link
Collaborator

A nightly compiler reports

/Users/mac/Desktop/test.swift:213:52: error: closure passed to parameter of type '(_: (String) -> (Int, Int))' that does not accept a closure [closure_bad_param]
let x = Transformer<String, (Int, Int)>(transform: { x in
                                                   ^~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. closures Feature: closures compiler The Swift compiler in itself generics Feature: generic declarations and types implicit conversions Feature: implicit conversions swift 6.0 tuples Feature: tuples type checker Area → compiler: Semantic analysis types Feature: types unexpected error Bug: Unexpected error variadic generics Feature → generics: Variadic generics
Projects
None yet
Development

No branches or pull requests

2 participants