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

Crash when using a logical operator inside pack iteration #73551

Open
simanerush opened this issue May 9, 2024 · 0 comments
Open

Crash when using a logical operator inside pack iteration #73551

simanerush opened this issue May 9, 2024 · 0 comments
Assignees
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 for-in loops Feature: for-in loops generics Feature: generic declarations and types pack iteration Feature → statements → for-in: Pack iteration SIL SILGen Area → compiler: The SIL generation stage statements Feature: statements swift 6.0 variadic generics Feature → generics: Variadic generics

Comments

@simanerush
Copy link
Member

simanerush commented May 9, 2024

Description

An unexpected crash occurs when trying to use a logical operator involving a pack element inside the body of pack iteration.

Stack trace:

Stack dump:
0.	Program arguments: ./swift-frontend ../../../../../Swift-Files/test.swift -typecheck -interpret
1.	Swift version 6.0-dev (LLVM ceb203a206ed550, Swift a5fdf158dc4292a)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
4.	While silgen emitFunction SIL function "@$s4testAAyyxxQpRvzAA15BoolConvertibleRzlF".
 for 'test(_:)' (at ../../../../../Swift-Files/test.swift:98: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           0x0000000108fe80ac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108fe6630 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108fe8710 SignalHandler(int) + 332
3  libsystem_platform.dylib 0x0000000181bcb584 _sigtramp + 56
4  swift-frontend           0x0000000104e81c84 swift::rewriting::RequirementMachine::verify(swift::rewriting::MutableTerm const&) const + 60
5  swift-frontend           0x0000000104e88e70 swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const::$_1::operator()(swift::Type) const::'lambda'()::operator()() const + 40
6  swift-frontend           0x0000000104e88c14 swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const::$_1::operator()(swift::Type) const + 520
7  swift-frontend           0x0000000104e889f0 std::__1::optional<swift::Type> llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>::callback_fn<swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const::$_1>(long, swift::TypeBase*) + 52
8  swift-frontend           0x00000001050632c8 llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>::operator()(swift::TypeBase*) const + 40
9  swift-frontend           0x0000000105063284 auto swift::Type::transformRec(llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>) const::$_19::operator()<swift::TypePosition>(swift::TypeBase*, swift::TypePosition) const + 40
10 swift-frontend           0x0000000105063240 std::__1::optional<swift::Type> llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>::callback_fn<swift::Type::transformRec(llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>) const::$_19>(long, swift::TypeBase*, swift::TypePosition) + 56
11 swift-frontend           0x000000010504ecf4 llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>::operator()(swift::TypeBase*, swift::TypePosition) const + 64
12 swift-frontend           0x000000010504a440 swift::Type::transformWithPosition(swift::TypePosition, llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*, swift::TypePosition)>) const + 188
13 swift-frontend           0x000000010504ec5c swift::Type::transformRec(llvm::function_ref<std::__1::optional<swift::Type> (swift::TypeBase*)>) const + 96
14 swift-frontend           0x0000000104e834f8 swift::rewriting::RequirementMachine::getReducedType(swift::Type, llvm::ArrayRef<swift::GenericTypeParamType*>) const + 92
15 swift-frontend           0x0000000104c61fe0 swift::GenericSignatureImpl::getReducedType(swift::Type) const + 164
16 swift-frontend           0x0000000104c61f24 swift::GenericSignature::getReducedType(swift::Type) const + 84
17 swift-frontend           0x000000010503fdc0 swift::TypeBase::getReducedType(swift::GenericSignature) + 52
18 swift-frontend           0x000000010313564c lowerCaptureContextParameters(swift::Lowering::TypeConverter&, swift::SILDeclRef, swift::CanGenericSignature, swift::TypeExpansionContext, llvm::SmallVectorImpl<swift::SILParameterInfo>&) + 1000
19 swift-frontend           0x00000001031341bc getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, std::__1::optional<swift::SILDeclRef>, std::__1::optional<swift::SILDeclRef>, std::__1::optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 3016
20 swift-frontend           0x0000000103132d44 getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, std::__1::optional<swift::SILDeclRef>, std::__1::optional<swift::SILDeclRef>, std::__1::optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef)::$_16::operator()((anonymous namespace)::Conventions const&) const + 324
21 swift-frontend           0x00000001031296fc getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, std::__1::optional<swift::SILDeclRef>, std::__1::optional<swift::SILDeclRef>, std::__1::optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 1076
22 swift-frontend           0x000000010312be08 getUncachedSILFunctionTypeForConstant(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::SILDeclRef, swift::Lowering::TypeConverter::LoweredFormalTypes) + 852
23 swift-frontend           0x000000010312c844 swift::Lowering::TypeConverter::getConstantInfo(swift::TypeExpansionContext, swift::SILDeclRef) + 404
24 swift-frontend           0x000000010191ce18 swift::Lowering::TypeConverter::getConstantFunctionType(swift::TypeExpansionContext, swift::SILDeclRef) + 104
25 swift-frontend           0x000000010311f280 swift::SILFunctionBuilder::getOrCreateFunction(swift::SILLocation, swift::SILDeclRef, swift::ForDefinition_t, llvm::function_ref<swift::SILFunction* (swift::SILLocation, swift::SILDeclRef)>, swift::ProfileCounter) + 184
26 swift-frontend           0x0000000101ea6d54 swift::SILFunction* swift::Lowering::SILGenFunctionBuilder::getOrCreateFunction<swift::SILLocation, swift::SILDeclRef&, swift::ForDefinition_t&, swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t)::$_0>(swift::SILLocation&&, swift::SILDeclRef&, swift::ForDefinition_t&, swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t)::$_0&&) + 176
27 swift-frontend           0x0000000101ea6970 swift::Lowering::SILGenModule::getFunction(swift::SILDeclRef, swift::ForDefinition_t) + 244
28 swift-frontend           0x0000000101ecd3d4 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&)::$_4::operator()() const + 136
29 swift-frontend           0x0000000101ecd340 void llvm::function_ref<void ()>::callback_fn<swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&)::$_4>(long) + 24
30 swift-frontend           0x00000001010ddca0 llvm::function_ref<void ()>::operator()() const + 32
31 swift-frontend           0x0000000103291b94 swift::Lowering::TypeConverter::withClosureTypeInfo(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&, llvm::function_ref<void ()>) + 268
32 swift-frontend           0x0000000101ead030 swift::Lowering::SILGenModule::emitClosure(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&) + 224
33 swift-frontend           0x0000000101fd5a80 (anonymous namespace)::RValueEmitter::emitClosureReference(swift::AbstractClosureExpr*, swift::Lowering::FunctionTypeInfo const&) + 68
34 swift-frontend           0x0000000101fd5578 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 472
35 swift-frontend           0x0000000101fc9a38 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visitAutoClosureExpr(swift::AutoClosureExpr*, swift::Lowering::SGFContext) + 72
36 swift-frontend           0x0000000101fb7734 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 1632
37 swift-frontend           0x0000000101fab3ac swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 204
38 swift-frontend           0x0000000101faef8c swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 76
39 swift-frontend           0x0000000101ef0aa8 (anonymous namespace)::ArgEmitter::emitDirect(swift::Lowering::ArgumentSource&&, swift::SILType, swift::Lowering::AbstractionPattern, swift::SILParameterInfo, std::__1::optional<swift::AnyFunctionType::Param>) + 564
40 swift-frontend           0x0000000101eedd94 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 1480
41 swift-frontend           0x0000000101edb964 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 340
42 swift-frontend           0x0000000101ee70a4 (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 356
43 swift-frontend           0x0000000101f101e4 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, swift::ForeignInfo const&) && + 336
44 swift-frontend           0x0000000101f0f134 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1116
45 swift-frontend           0x0000000101f0e630 (anonymous namespace)::CallEmission::applyNormalCall(swift::Lowering::SGFContext) + 772
46 swift-frontend           0x0000000101f0d56c (anonymous namespace)::CallEmission::applyFirstLevelCallee(swift::Lowering::SGFContext) + 200
47 swift-frontend           0x0000000101eddfc8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 108
48 swift-frontend           0x0000000101eddaf0 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 96
49 swift-frontend           0x0000000101fdda9c (anonymous namespace)::RValueEmitter::visitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 76
50 swift-frontend           0x0000000101fcbbc0 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visitBinaryExpr(swift::BinaryExpr*, swift::Lowering::SGFContext) + 72
51 swift-frontend           0x0000000101fb79d4 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 2304
52 swift-frontend           0x0000000101fab3ac swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 204
53 swift-frontend           0x0000000101e57c68 swift::Lowering::ArgumentSource::getAsRValue(swift::Lowering::SILGenFunction&, swift::Lowering::SGFContext) && + 236
54 swift-frontend           0x000000010202f72c swift::Lowering::SILGenFunction::emitAssignToLValue(swift::SILLocation, swift::Lowering::ArgumentSource&&, swift::Lowering::LValue&&) + 376
55 swift-frontend           0x0000000101fe2d80 emitSimpleAssignment(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Expr*, swift::Expr*) + 1204
56 swift-frontend           0x0000000101fd16c8 (anonymous namespace)::RValueEmitter::visitAssignExpr(swift::AssignExpr*, swift::Lowering::SGFContext) + 172
57 swift-frontend           0x0000000101fb7f54 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 3712
58 swift-frontend           0x0000000101fab3ac swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 204
59 swift-frontend           0x0000000101faf994 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 1460
60 swift-frontend           0x00000001020dda04 (anonymous namespace)::StmtEmitter::visitBraceStmt(swift::BraceStmt*) + 1844
61 swift-frontend           0x00000001020d8584 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 96
62 swift-frontend           0x00000001020e2d98 (anonymous namespace)::StmtEmitter::visitForEachStmt(swift::ForEachStmt*)::$_3::operator()(swift::SILValue, swift::SILValue, swift::SILValue) const + 400
63 swift-frontend           0x00000001020e2bfc void llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>::callback_fn<(anonymous namespace)::StmtEmitter::visitForEachStmt(swift::ForEachStmt*)::$_3>(long, swift::SILValue, swift::SILValue, swift::SILValue) + 72
64 swift-frontend           0x00000001020541f8 llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>::operator()(swift::SILValue, swift::SILValue, swift::SILValue) const + 80
65 swift-frontend           0x0000000102053088 swift::Lowering::SILGenFunction::emitDynamicPackLoop(swift::SILLocation, swift::CanTypeWrapper<swift::PackType>, unsigned int, swift::SILValue, swift::SILValue, swift::GenericEnvironment*, bool, llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>, swift::SILBasicBlock*) + 2616
66 swift-frontend           0x0000000102053eac swift::Lowering::SILGenFunction::emitDynamicPackLoop(swift::SILLocation, swift::CanTypeWrapper<swift::PackType>, unsigned int, swift::GenericEnvironment*, llvm::function_ref<void (swift::SILValue, swift::SILValue, swift::SILValue)>, swift::SILBasicBlock*) + 188
67 swift-frontend           0x00000001020df63c (anonymous namespace)::StmtEmitter::visitForEachStmt(swift::ForEachStmt*) + 400
68 swift-frontend           0x00000001020d8634 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 272
69 swift-frontend           0x00000001020dd964 (anonymous namespace)::StmtEmitter::visitBraceStmt(swift::BraceStmt*) + 1684
70 swift-frontend           0x00000001020d8584 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 96
71 swift-frontend           0x00000001020d84e4 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 48
72 swift-frontend           0x0000000101ffb524 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 792
73 swift-frontend           0x0000000101ea9088 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 3156
74 swift-frontend           0x0000000101eab924 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 428
75 swift-frontend           0x0000000101ea8400 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 416
76 swift-frontend           0x0000000101ea8254 swift::Lowering::SILGenModule::visitFuncDecl(swift::FuncDecl*) + 32
77 swift-frontend           0x0000000101ea7f70 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 972
78 swift-frontend           0x0000000101ea7b94 swift::Lowering::SILGenModule::visit(swift::Decl*) + 60
79 swift-frontend           0x0000000101eaffbc (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 308
80 swift-frontend           0x0000000101eafb6c swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 676
81 swift-frontend           0x00000001020d7778 std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 116
82 swift-frontend           0x00000001020d76c4 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 40
83 swift-frontend           0x0000000101ecec14 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'()) + 248
84 swift-frontend           0x0000000101eceb10 swift::ASTLoweringRequest::OutputType swift::Evaluator::operator()<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'(), (void*)0>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 40
85 swift-frontend           0x0000000101eb05f8 swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest) + 40
86 swift-frontend           0x0000000101eb0518 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 184
87 swift-frontend           0x00000001010fdadc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 240
88 swift-frontend           0x000000010112daf8 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_28::operator()(swift::CompilerInstance&) const + 140
89 swift-frontend           0x000000010112da5c bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_28>(long, swift::CompilerInstance&) + 32
90 swift-frontend           0x000000010112cf14 llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 40
91 swift-frontend           0x000000010112bdd4 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 452
92 swift-frontend           0x0000000101126980 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1164
93 swift-frontend           0x000000010110085c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 256
94 swift-frontend           0x00000001010ff504 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2336
95 swift-frontend           0x0000000100f99ba4 run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 1720
96 swift-frontend           0x0000000100f98a44 swift::mainEntry(int, char const**) + 1148
97 swift-frontend           0x0000000100f980a4 main + 36
98 dyld                     0x00000001818120e0 start + 2360

Reproduction

protocol BoolConvertible {
  func toBool() -> Bool
}

func test<each T: BoolConvertible>(_ t: repeat each T) {
  var res = false
  for x in repeat each t {
    res = res || x.toBool()
  }
}

Expected behavior

The program should compile.

Environment

Swift version 6.0-dev (LLVM ceb203a206ed550, Swift a5fdf15)

Additional information

A workaround of the above bug:

protocol BoolConvertible {
  func toBool() -> Bool
}

func test<each T: BoolConvertible>(_ t: repeat each T) {
  var res = false
  for x in repeat each t {
    let r = x.toBool()
    res = res || r
  }
}

If the result of a call to the function required by the protocol conformance is saved to a variable, the compilation succeeds.

@simanerush simanerush added SILGen Area → compiler: The SIL generation stage verifier crash Bug: A crash, i.e., an abnormal termination of software SIL variadic generics Feature → generics: Variadic generics pack iteration Feature → statements → for-in: Pack iteration labels May 9, 2024
@simanerush simanerush self-assigned this May 9, 2024
@AnthonyLatsis AnthonyLatsis added generics Feature: generic declarations and types compiler The Swift compiler in itself swift 6.0 bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. for-in loops Feature: for-in loops statements Feature: statements labels May 10, 2024
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 for-in loops Feature: for-in loops generics Feature: generic declarations and types pack iteration Feature → statements → for-in: Pack iteration SIL SILGen Area → compiler: The SIL generation stage statements Feature: statements swift 6.0 variadic generics Feature → generics: Variadic generics
Projects
None yet
Development

No branches or pull requests

3 participants
@AnthonyLatsis @simanerush and others