Skip to content

Crash: Static member lookup in existential context #61645

@stephencelis

Description

@stephencelis

Describe the bug

Static member lookup in an existential context crashes the compiler. While SE-299 extended static member lookup to generic contexts, it appears to be broken in existential ones.

Steps To Reproduce

Try to compile the following:

@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *)
func f() {
  let clock: any Clock<Duration> = .continuous
}

And you'll get a crash:

1.	Apple Swift version 5.7.1 (swiftlang-5.7.1.135.2 clang-1400.0.29.51)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "crasher.swift")
4.	While emitting IR SIL function "@$s6Crasher1fyyF".
 for 'f()' (at crasher:2:1)
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           0x0000000106fe75b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106fe65b4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106fe7c34 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x000000018181f4a4 _sigtramp + 56
4  swift-frontend           0x0000000102a4bb34 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 65060
5  swift-frontend           0x0000000102a4bb34 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 65060
6  swift-frontend           0x0000000102a36d84 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 7860
7  swift-frontend           0x0000000102903418 swift::irgen::IRGenerator::emitGlobalTopLevel(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&) + 1552
8  swift-frontend           0x0000000102a04bec swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2556
9  swift-frontend           0x0000000102a34c04 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 188
10 swift-frontend           0x0000000102a110e0 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 744
11 swift-frontend           0x0000000102a07fd4 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 236
12 swift-frontend           0x0000000102632b40 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*) + 2160
13 swift-frontend           0x00000001026348cc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5932
14 swift-frontend           0x00000001025d53c0 swift::mainEntry(int, char const**) + 3940
15 dyld                     0x00000001097b108c start + 520

Expected behavior

Ideally it should compile fine. Less ideally it should emit an error describing the limitation.

Environment (please fill out the following information)

  • OS: macOS 12 (N/A)
  • Xcode Version/Tag/Branch: 14.1 RC

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwareduplicateResolution: Duplicates another issuetype checkerArea → compiler: Semantic analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions