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
[SR-11769] Crash when attempting to assign an unbound method from a protocol #54176
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
type checker
Area → compiler: Semantic analysis
Comments
Reproduced in master. As far as I know, it's legal to get an unbound method from a protocol existential, which means this code should be valid. brent@broyalgordon /V/D/C/o/swift a-link-to-the-past-5.1> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-11-01-a.xctoolchain/usr/bin/swift sr-11769.swift
not existential
UNREACHABLE executed at /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/SILGen/SILGenConvert.cpp:987!
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-11-01-a.xctoolchain/usr/bin/swift -frontend -interpret sr-11769.swift -enable-objc-interop -sdk /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name main
1. Apple Swift version 5.1.1-dev (Swift 74328cdda2)
0 swift 0x000000011214fc35 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1 swift 0x000000011214eee5 llvm::sys::RunSignalHandlers() + 85
2 swift 0x0000000112150218 SignalHandler(int) + 264
3 libsystem_platform.dylib 0x00007fff624abb1d _sigtramp + 29
4 swift 0x000000011331f1de llvm::itanium_demangle::PixelVectorType::printLeft(llvm::itanium_demangle::OutputStream&) const (.cold.1) + 254014
5 libsystem_c.dylib 0x00007fff62381a08 abort + 120
6 swift 0x00000001132d293e llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 462
7 swift 0x000000010e88fcc3 swift::Lowering::SILGenFunction::emitOpenExistential(swift::SILLocation, swift::Lowering::ManagedValue, swift::SILType, swift::AccessKind) + 1203
8 swift 0x000000010e8ae85a swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 314
9 swift 0x000000010e8bed35 swift::Lowering::RValue swift::Lowering::SILGenFunction::emitOpenExistentialExpr<swift::Lowering::RValue, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_16>(swift::OpenExistentialExpr*, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_16) + 69
10 swift 0x000000010e8b0b37 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 4695
11 swift 0x000000010e8a2c6f swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 303
12 swift 0x000000010e8949af swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 335
13 swift 0x000000010e894a8d swift::Lowering::SILGenFunction::visitPatternBindingDecl(swift::PatternBindingDecl*) + 45
14 swift 0x000000010e84a492 swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 498
15 swift 0x000000010e84a9b3 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 915
16 swift 0x000000010e84b959 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&, swift::FileUnit*) + 393
17 swift 0x000000010e84bd21 swift::performSILGeneration(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions&) + 17
18 swift 0x000000010e553cd0 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 7808
19 swift 0x000000010e550ed6 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3046
20 swift 0x000000010e4f62d9 main + 729
21 libdyld.dylib 0x00007fff622aa325 start + 1
22 libdyld.dylib 0x000000000000000a start + 2648005862
(open_existential_expr implicit type='(S) -> () -> ()' location=sr-11769.swift:6:9 range=[sr-11769.swift:6:9 - line:6:11]
(opaque_value_expr implicit type='(S).Type' location=sr-11769.swift:6:9 range=[sr-11769.swift:6:9 - line:6:9] @ 0x1100e0520)
(type_expr type='S.Protocol' location=sr-11769.swift:6:9 range=[sr-11769.swift:6:9 - line:6:9] typerepr='S')
(dot_syntax_base_ignored type='(S) -> () -> ()' location=sr-11769.swift:6:9 range=[sr-11769.swift:6:9 - line:6:11]
(metatype_conversion_expr implicit type='S.Protocol' location=sr-11769.swift:6:9 range=[sr-11769.swift:6:9 - line:6:9]
(opaque_value_expr implicit type='(S).Type' location=sr-11769.swift:6:9 range=[sr-11769.swift:6:9 - line:6:9] @ 0x1100e0520))
(declref_expr type='(S) -> () -> ()' location=sr-11769.swift:6:11 range=[sr-11769.swift:6:11 - line:6:11] decl=main.(file).S extension.a()@sr-11769.swift:4:8 [with (substitution_map generic_signature=<Self where Self : S> (substitution Self -> S))] function_ref=unapplied))) That AST smells funny to me. @xedin? |
@swift-ci create |
Dup of SR-75. |
AnthonyLatsis
added
CompilerCrash
and removed
generics
Feature: generic declarations and types
labels
Sep 17, 2022
This issue was closed.
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.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
type checker
Area → compiler: Semantic analysis
Environment
macOS 10.14.6
Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)
Target: x86_64-apple-darwin18.7.0
Additional Detail from JIRA
md5: ca3f5f0da607d96f6ed538ca5e76bb34
duplicates:
Issue Description:
The following code will crash the compiler (Swift 5.1.2):
Of course, this would work perfectly if `S` was a struct (or class) rather than a protocol. If the same behavior is not meant to be supported, then the compiler should issue an error message at line 6.
Here's my stack dump:
The text was updated successfully, but these errors were encountered: