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

[AutoDiff] Crash when protocol conditional conformance to Differentiable is missed #78370

Open
kovdan01 opened this issue Dec 27, 2024 · 2 comments
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself conformances Feature → protocol: protocol conformances crash Bug: A crash, i.e., an abnormal termination of software failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression type checker Area → compiler: Semantic analysis

Comments

@kovdan01
Copy link
Contributor

Description

With where Self : Differentiable commented out in the reproducer below, we get a crash. When uncommented, the code compiles with no issues. See also #77446 (comment)

Reproduction

protocol AdditiveArithmetic: Equatable /*where Self : Differentiable*/{
  @differentiable(reverse, wrt: (lhs, rhs))
  static func +(lhs: Self, rhs: Self) -> Self
}

struct Foo: AdditiveArithmetic {
  static func +(lhs: Self, rhs: Self) -> Self {
    lhs
  }
}

Stack dump

error: compile command failed due to signal 6 (use -v to see invocation)
                                                                                                                                                                                                                                                                
getReducedTypeParameter() was called
       with <τ_0_0 where τ_0_0 : AdditiveArithmetic>,
       and τ_0_0.TangentVector.
                                                                                                                                                                                                                                                                
This type parameter's reduced term is τ_0_0.[Differentiable:TangentVector].
                                                                                                                                                                                                                                                                
This is not a valid term, because τ_0_0 does not have a member type named [Differentiable:TangentVector].
                                                                                                                                                                                                                                                                
This usually indicates the caller passed the wrong type or generic signature to getReducedType().
                                                                                                                                                                                                                                                                
Requirement machine for <τ_0_0 where τ_0_0 : AdditiveArithmetic>
Rewrite system: {
- [AdditiveArithmetic].[AdditiveArithmetic] => [AdditiveArithmetic] [permanent]
- [AdditiveArithmetic].[Equatable] => [AdditiveArithmetic] [explicit]
- [AdditiveArithmetic].[Copyable] => [AdditiveArithmetic] [explicit]
- [AdditiveArithmetic].[Escapable] => [AdditiveArithmetic] [explicit]
- [Equatable].[Equatable] => [Equatable] [permanent]
- [Equatable].[Copyable] => [Equatable] [explicit]
- [Equatable].[Escapable] => [Equatable] [explicit]
- [Copyable].[Copyable] => [Copyable] [permanent]
- [Escapable].[Escapable] => [Escapable] [permanent]
- τ_0_0.[AdditiveArithmetic] => τ_0_0 [explicit]
- τ_0_0.[Equatable] => τ_0_0
- τ_0_0.[Copyable] => τ_0_0
- τ_0_0.[Escapable] => τ_0_0
}
Property map: {
  [AdditiveArithmetic] => { conforms_to: [AdditiveArithmetic Equatable Copyable Escapable] }
  [Equatable] => { conforms_to: [Equatable Copyable Escapable] }
  [Copyable] => { conforms_to: [Copyable] }
  [Escapable] => { conforms_to: [Escapable] }
  τ_0_0 => { conforms_to: [AdditiveArithmetic Equatable Copyable Escapable] }
}
Conformance paths: {
}
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /path/to/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin/swift-frontend -frontend -c -primary-file 32.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -empty-abi-descr
iptor -resource-dir /path/to/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift -module-name main -in-process-plugin-server-path /path/to/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift
/host/libSwiftInProcPluginServer.so -plugin-path /path/to/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/lib/swift/host/plugins -plugin-path /path/to/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/loc
al/lib/swift/host/plugins -o /tmp/TemporaryDirectory.IuRRrR/32-1.o
1.      Swift version 6.2-dev (LLVM 9f6c3d784782c34, Swift 311f449eb52d9a5)
2.      Compiling with effective version 5.10
3.      While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "32.swift")
4.      While generating SIL witness table protocol conformance Foo: AdditiveArithmetic at 'Foo' (at 32.swift:15:1)
5.      While computing canonical type for  type '@convention(thin) <Self where Self : AdditiveArithmetic> (τ_0_0.Type) -> (τ_0_0, τ_0_0) -> (τ_0_0, (τ_0_0.TangentVector, τ_0_0.TangentVector) -> τ_0_0.TangentVector)'
 #0 0x00000c8a4ca3acf8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /path/to/swift/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x00000c8a4ca38e20 llvm::sys::RunSignalHandlers() /path/to/swift/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x00000c8a4ca3b378 SignalHandler(int) /path/to/swift/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x000060905964c1d0 (/usr/lib/libc.so.6+0x3d1d0)
 #4 0x00006090596a53f4 __pthread_kill_implementation /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:44:76
 #5 0x000060905964c120 raise /usr/src/debug/glibc/glibc/signal/../sysdeps/posix/raise.c:27:6
 #6 0x00006090596334c3 abort /usr/src/debug/glibc/glibc/stdlib/abort.c:81:7
 #7 0x00000c8a475ee53b llvm::SmallVectorTemplateCommon<swift::rewriting::Symbol, void>::operator[](unsigned long) /path/to/swift/llvm-project/llvm/include/llvm/ADT/SmallVector.h:305:5
 #8 0x00000c8a475ee53b swift::rewriting::MutableTerm::operator[](unsigned long) /path/to/swift/swift/lib/AST/RequirementMachine/Term.h:192:12
 #9 0x00000c8a475ee53b swift::rewriting::RequirementMachine::getReducedTypeParameter(swift::CanType, llvm::ArrayRef<swift::GenericTypeParamType*>) const /path/to/swift/swift/lib/AST/RequirementMachine/GenericSignatureQueries.cpp:451:54
#10 0x00000c8a475f0f2f swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const::$_0::operator()(swift::Type) const /path/to/swift/swift/lib/AST/RequirementMachine/GenericSignatu
reQueries.cpp:0:12
#11 0x00000c8a475f0f2f std::optional<swift::Type> llvm::function_ref<std::optional<swift::Type> (swift::TypeBase*)>::callback_fn<swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const::$_0>(lon
g, swift::TypeBase*) /path/to/swift/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#12 0x00000c8a476904d1 std::_Optional_base_impl<swift::Type, std::_Optional_base<swift::Type, true, true>>::_M_is_engaged() const /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:469:58
#13 0x00000c8a476904d1 std::optional<swift::Type>::operator bool() const /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:983:22
#14 0x00000c8a476904d1 swift::TypeTransform<swift::Type::transformRec(llvm::function_ref<std::optional<swift::Type> (swift::TypeBase*)>) const::Transform>::doIt(swift::Type, swift::TypePosition) /path/to/swift/swift/include/swift/AST/TypeT
ransform.h:98:29
#15 0x00000c8a47690734 swift::TypeTransform<swift::Type::transformRec(llvm::function_ref<std::optional<swift::Type> (swift::TypeBase*)>) const::Transform>::doIt(swift::Type, swift::TypePosition) /path/to/swift/swift/include/swift/AST/TypeT
ransform.h:777:26
#16 0x00000c8a47690dd5 swift::Type::operator bool() const /path/to/swift/swift/include/swift/AST/Type.h:245:47
#17 0x00000c8a47690dd5 swift::TypeTransform<swift::Type::transformRec(llvm::function_ref<std::optional<swift::Type> (swift::TypeBase*)>) const::Transform>::doIt(swift::Type, swift::TypePosition) /path/to/swift/swift/include/swift/AST/TypeT
ransform.h:699:14
#18 0x00000c8a47691bd2 swift::TypeTransform<swift::Type::transformRec(llvm::function_ref<std::optional<swift::Type> (swift::TypeBase*)>) const::Transform>::doIt(swift::Type, swift::TypePosition) /path/to/swift/swift/include/swift/AST/TypeT
ransform.h:0:23
#19 0x00000c8a476825c3 swift::Type::transformRec(llvm::function_ref<std::optional<swift::Type> (swift::TypeBase*)>) const /path/to/swift/swift/lib/AST/Type.cpp:4154:3
#20 0x00000c8a475ee825 swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const /path/to/swift/swift/lib/AST/RequirementMachine/GenericSignatureQueries.cpp:480:3
#21 0x00000c8a47526420 swift::Type::operator->() const /path/to/swift/swift/include/swift/AST/Type.h:241:5
#22 0x00000c8a47526420 swift::GenericSignatureImpl::getReducedType(swift::Type) const /path/to/swift/swift/lib/AST/GenericSignature.cpp:520:10
#23 0x00000c8a47687dfe swift::TypeBase::getReducedType(swift::GenericSignature) /path/to/swift/swift/lib/AST/Type.cpp:1865:14
#24 0x00000c8a47687dfe swift::TypeBase::computeCanonicalType() /path/to/swift/swift/lib/AST/Type.cpp:1752:42
#25 0x00000c8a46a88bca llvm::isa_impl_cl<swift::AnyFunctionType, swift::TypeBase const*>::doit(swift::TypeBase const*) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:109:5
#26 0x00000c8a46a88bca llvm::isa_impl_wrap<swift::AnyFunctionType, swift::TypeBase const*, swift::TypeBase const*>::doit(swift::TypeBase const* const&) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:137:12
#27 0x00000c8a46a88bca llvm::isa_impl_wrap<swift::AnyFunctionType, swift::TypeBase const* const, swift::TypeBase const*>::doit(swift::TypeBase const* const&) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:127:12
#28 0x00000c8a46a88bca llvm::CastIsPossible<swift::AnyFunctionType, swift::TypeBase const*, void>::isPossible(swift::TypeBase const* const&) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:255:12
#29 0x00000c8a46a88bca llvm::CastInfo<swift::AnyFunctionType, swift::TypeBase* const, void>::isPossible(swift::TypeBase* const&) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:509:12
#30 0x00000c8a46a88bca bool llvm::isa<swift::AnyFunctionType, swift::TypeBase*>(swift::TypeBase* const&) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:549:10
#31 0x00000c8a46a88bca decltype(auto) llvm::cast<swift::AnyFunctionType, swift::TypeBase>(swift::TypeBase*) /path/to/swift/llvm-project/llvm/include/llvm/Support/Casting.h:578:3
#32 0x00000c8a46a88bca swift::CanTypeWrapper<swift::AnyFunctionType> swift::cast<swift::AnyFunctionType>(swift::CanType) /path/to/swift/swift/include/swift/AST/Type.h:620:28
#33 0x00000c8a46a88bca swift::Lowering::TypeConverter::makeConstantInterfaceType(swift::SILDeclRef) /path/to/swift/swift/lib/SIL/IR/TypeLowering.cpp:4119:12
#34 0x00000c8a469e86eb swift::Lowering::TypeConverter::getConstantInfo(swift::TypeExpansionContext, swift::SILDeclRef) /path/to/swift/swift/lib/SIL/IR/SILFunctionType.cpp:4162:30
#35 0x00000c8a4604410e swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::SerializedKind_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) /path/to/swift/swift/lib/SILGen/SILGenType.cpp:717:13
#36 0x00000c8a4604857d (anonymous namespace)::SILGenConformance::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) /path/to/swift/swift/lib/SILGen/SILGenType.cpp:652:34
#37 0x00000c8a4604857d (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) /path/to/swift/swift/lib/SILGen/SILGenType.cpp:488:17
#38 0x00000c8a46047ee7 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) /path/to/swift/swift/lib/SILGen/SILGenType.cpp:0:0
#39 0x00000c8a46048148 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::addAutoDiffDerivativeMethodsIfRequired(swift::AbstractFunctionDecl*, swift::SILDeclRef::Kind) /path/to/swift/swift/include/swift/SIL/SILWitnessVisitor.h:184:19
#40 0x00000c8a4604755a swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitFuncDecl(swift::FuncDecl*) /path/to/swift/swift/include/swift/SIL/SILWitnessVisitor.h:156:5
#41 0x00000c8a4604755a swift::ASTVisitor<(anonymous namespace)::SILGenConformance, void, void, void, void, void, void>::visit(swift::Decl*) /path/to/swift/swift/include/swift/AST/DeclNodes.def:178:5
#42 0x00000c8a4604755a swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) /path/to/swift/swift/include/swift/SIL/SILWitnessVisitor.h:111:22
#43 0x00000c8a46043e6e (anonymous namespace)::SILGenConformance::addConditionalRequirements() /path/to/swift/swift/lib/SILGen/SILGenType.cpp:683:9
#44 0x00000c8a46043e6e (anonymous namespace)::SILGenConformance::emit() /path/to/swift/swift/lib/SILGen/SILGenType.cpp:551:5
#45 0x00000c8a46043e6e swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) /path/to/swift/swift/lib/SILGen/SILGenType.cpp:706:66
#46 0x00000c8a46046b95 (anonymous namespace)::SILGenType::emitType() /path/to/swift/swift/lib/SILGen/SILGenType.cpp:0:19
#47 0x00000c8a46046398 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) /path/to/swift/swift/lib/SILGen/SILGenType.cpp:1320:1
#48 0x00000c8a45f242f3 swift::Lowering::SILGenModule::visit(swift::Decl*) /path/to/swift/swift/lib/SILGen/SILGen.cpp:0:15
#49 0x00000c8a45f242f3 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) /path/to/swift/swift/lib/SILGen/SILGen.cpp:2100:5
#50 0x00000c8a45f24a34 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const /path/to/swift/swift/lib/SILGen/SILGen.cpp:0:11
#51 0x00000c8a4602e5a8 std::_Optional_payload_base<llvm::SmallVector<swift::SymbolSource, 1u>>::_M_reset() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:313:12
#52 0x00000c8a4602e5a8 std::_Optional_payload<llvm::SmallVector<swift::SymbolSource, 1u>, false, false, false>::~_Optional_payload() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:437:57
#53 0x00000c8a4602e5a8 std::_Optional_base<llvm::SmallVector<swift::SymbolSource, 1u>, false, false>::~_Optional_base() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:508:12
#54 0x00000c8a4602e5a8 swift::ASTLoweringDescriptor::~ASTLoweringDescriptor() /path/to/swift/swift/include/swift/AST/SILGenRequests.h:50:8
#55 0x00000c8a4602e5a8 std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::callDerived<0ul>(swift::Evaluator&, std::integer_sequence<unsigned long, 0ul>) const /path/to/swift/swift/include/swift/AST/SimpleRequest.h:287:5
#56 0x00000c8a4602e5a8 swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) /path/to/swift/swift/include/swift/AST/SimpleRequest.h:311:20
#57 0x00000c8a45f29b5c swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) /path/to/swift/swift/include/swift/AST/Evaluator.h:349:14
#58 0x00000c8a45f25352 std::_Optional_payload_base<llvm::SmallVector<swift::SymbolSource, 1u>>::_M_reset() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:313:12
#59 0x00000c8a45f25352 std::_Optional_payload<llvm::SmallVector<swift::SymbolSource, 1u>, false, false, false>::~_Optional_payload() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:437:57
#60 0x00000c8a45f25352 std::_Optional_base<llvm::SmallVector<swift::SymbolSource, 1u>, false, false>::~_Optional_base() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/optional:508:12
#61 0x00000c8a45f25352 swift::ASTLoweringDescriptor::~ASTLoweringDescriptor() /path/to/swift/swift/include/swift/AST/SILGenRequests.h:50:8
#62 0x00000c8a45f25352 std::_Head_base<0ul, swift::ASTLoweringDescriptor, false>::~_Head_base() /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/tuple:196:12
#63 0x00000c8a45f25352 swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::~SimpleRequest() /path/to/swift/swift/include/swift/AST/SimpleRequest.h:272:7
#64 0x00000c8a45f25352 swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) /path/to/swift/swift/lib/SILGen/SILGen.cpp:2272:3
#65 0x00000c8a4575c768 std::_Tuple_impl<0ul, swift::SILModule*, std::default_delete<swift::SILModule>>::_Tuple_impl(std::_Tuple_impl<0ul, swift::SILModule*, std::default_delete<swift::SILModule>>&&) /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/tuple:326:7
#66 0x00000c8a4575c768 std::tuple<swift::SILModule*, std::default_delete<swift::SILModule>>::tuple(std::tuple<swift::SILModule*, std::default_delete<swift::SILModule>>&&) /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/tuple:2132:17
#67 0x00000c8a4575c768 std::__uniq_ptr_impl<swift::SILModule, std::default_delete<swift::SILModule>>::__uniq_ptr_impl(std::__uniq_ptr_impl<swift::SILModule, std::default_delete<swift::SILModule>>&&) /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:179:9
#68 0x00000c8a4575c768 std::__uniq_ptr_data<swift::SILModule, std::default_delete<swift::SILModule>, true, true>::__uniq_ptr_data(std::__uniq_ptr_data<swift::SILModule, std::default_delete<swift::SILModule>, true, true>&&) /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:236:7
#69 0x00000c8a4575c768 std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>::unique_ptr(std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>&&) /sbin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/unique_ptr.h:360:7
#70 0x00000c8a4575c768 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) /path/to/swift/swift/lib/FrontendTool/FrontendTool.cpp:747:57
#71 0x00000c8a4576d72a withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) /path/to/swift/swift/lib/FrontendTool/FrontendTool.cpp:1155:25
#72 0x00000c8a4575f7a6 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) /path/to/swift/swift/lib/FrontendTool/FrontendTool.cpp:0:12
#73 0x00000c8a4575f7a6 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) /path/to/swift/swift/lib/FrontendTool/FrontendTool.cpp:1368:19
#74 0x00000c8a4575e968 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) /path/to/swift/swift/lib/FrontendTool/FrontendTool.cpp:0:19
#75 0x00000c8a454fc40e run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) /path/to/swift/swift/lib/DriverTool/driver.cpp:0:0
#76 0x00000c8a454fc40e swift::mainEntry(int, char const**) /path/to/swift/swift/lib/DriverTool/driver.cpp:530:10
#77 0x0000609059634e08 __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#78 0x0000609059634ecc call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:128:20
#79 0x0000609059634ecc __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:347:5
#80 0x00000c8a454fb3c5 _start (/path/to/swift/build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin/swift-frontend+0xcb83c5)

Expected behavior

Emit an error like the following (autodiff_attr_result_not_differentiable)

error: can only differentiate functions with results that conform to 'Differentiable', but 'Foo' does not conform to 'Differentiable'

Environment

Swift version 6.2-dev

Additional information

No response

@kovdan01 kovdan01 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 Dec 27, 2024
@kovdan01
Copy link
Contributor Author

Tagging @asl @JaapWijnen

@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself AutoDiff type checker Area → compiler: Semantic analysis conformances Feature → protocol: protocol conformances and removed triage needed This issue needs more specific labels labels Dec 27, 2024
@asl asl added the failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression label Dec 27, 2024
@asl
Copy link
Contributor

asl commented Dec 27, 2024

We fail to produce proper diagnostics here and instead proceed to type checking

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself conformances Feature → protocol: protocol conformances crash Bug: A crash, i.e., an abnormal termination of software failed to produce diagnostic Bug → internal error: Failed to produce diagnostic for expression type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants