swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.39k stars 10.35k forks source link

[SR-14399] Compiler crash with Self as closure parameter #56757

Open theblixguy opened 3 years ago

theblixguy commented 3 years ago
Previous ID SR-14399
Radar rdar://problem/75839792
Original Reporter @theblixguy
Type Bug
Environment Swift version 5.4-dev (LLVM bd2476a8056e227, Swift 14c18531a3b3d95) Target: x86_64-apple-darwin20.3.0 OS: macOS Big Sur 11.2.3
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, SILGen, TypeChecker | |Assignee | None | |Priority | Medium | md5: 5d60f820e589fc287538e4bf6877aec7

Issue Description:

The following code crashes in the CSApply:

class A {}

extension A {
  func closure(_: @escaping (Self) -> Void) {}
}

let a = A()
_ = a.closure({ _ in })
Unhandled coercion
UNREACHABLE executed at /Users/suyashsrijan/Documents/swift-project/swift/lib/Sema/CSApply.cpp:7041!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /Users/suyashsrijan/Documents/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift-frontend -frontend -interpret /Users/suyashsrijan/Desktop/test.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -color-diagnostics -target-sdk-version 11.1 -module-name test
1.  Swift version 5.4-dev (LLVM bd2476a8056e227, Swift 14c18531a3b3d95)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "/Users/suyashsrijan/Desktop/test.swift")
3.  While type-checking statement at [/Users/suyashsrijan/Desktop/test.swift:8:1 - line:8:23] RangeText="_ = a.closure({ _ in }"
4.  While type-checking expression at [/Users/suyashsrijan/Desktop/test.swift:8:1 - line:8:23] RangeText="_ = a.closure({ _ in }"
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           0x0000000110937d37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x0000000110936e05 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x0000000110938366 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20487d7d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000000046 _sigtramp + 18446603339974542054
5  libsystem_c.dylib        0x00007fff20396720 abort + 120
6  swift-frontend           0x0000000110889652 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 482
7  swift-frontend           0x000000010c7bf208 (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder, llvm::Optional<swift::Pattern*>) + 12184
8  swift-frontend           0x000000010c7c4c30 swift::ASTVisitor<(anonymous namespace)::ExprRewriter, swift::Expr*, void, void, void, void, void>::visit(swift::Expr*) + 9648
9  swift-frontend           0x000000010c7c09d6 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) + 22
10 swift-frontend           0x000000010cc22fd3 swift::Expr::walk(swift::ASTWalker&) + 115
11 swift-frontend           0x000000010c7b9ee8 (anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SolutionApplicationTarget) + 136
12 swift-frontend           0x000000010c7b9cae swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SolutionApplicationTarget) + 622
13 swift-frontend           0x000000010c980c79 swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 633
14 swift-frontend           0x000000010c98097d swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 77
15 swift-frontend           0x000000010ca4157b (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 235
16 swift-frontend           0x000000010ca4350c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 124
17 swift-frontend           0x000000010ca42880 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 128
18 swift-frontend           0x000000010ca42902 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 50
19 swift-frontend           0x000000010ca7673f swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 223
20 swift-frontend           0x000000010ca778ff llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 415
21 swift-frontend           0x000000010ca776b4 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 100
22 swift-frontend           0x000000010ca76580 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
23 swift-frontend           0x000000010bcc6a4e swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 174
24 swift-frontend           0x000000010bcc68ea swift::CompilerInstance::performSema() + 74
25 swift-frontend           0x000000010bb58d74 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4724
26 swift-frontend           0x000000010baa9847 main + 519
27 libdyld.dylib            0x00007fff2045e621 start + 1
28 libdyld.dylib            0x000000000000000c start + 18446603339974711788
zsh: abort      ./swift ~/Desktop/test.swift

If you remove the discard assignment, then it crashes in SIL:

class A {}

extension A {
  func closure(_: @escaping (Self) -> Void) {}
}

let a = A()
a.closure({ _ in })
Assertion failed: (hasDynamicSelfMetadata() && "This method can only be called if the " "SILFunction has a self-metadata parameter"), function getDynamicSelfMetadata, file /Users/suyashsrijan/Documents/swift-project/swift/include/swift/SIL/SILFunction.h, line 1138.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /Users/suyashsrijan/Documents/swift-project/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift-frontend -frontend -interpret /Users/suyashsrijan/Desktop/test.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -color-diagnostics -target-sdk-version 11.1 -module-name test
1.  Swift version 5.4-dev (LLVM bd2476a8056e227, Swift 14c18531a3b3d95)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
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           0x000000010a50ad37 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010a509e05 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010a50b366 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff20487d7d _sigtramp + 29
4  swift-frontend           0x000000010d947748 cmark_strbuf__initbuf + 215043
5  libsystem_c.dylib        0x00007fff20396720 abort + 120
6  libsystem_c.dylib        0x00007fff203959d6 err + 0
7  swift-frontend           0x000000010a5c1003 collectTypeDependentOperands(llvm::SmallVectorImpl<swift::SILValue>&, swift::SILOpenedArchetypesState&, swift::SILFunction&, swift::CanType, swift::SubstitutionMap) (.cold.4) + 35
8  swift-frontend           0x00000001059248f7 collectTypeDependentOperands(llvm::SmallVectorImpl<swift::SILValue>&, swift::SILOpenedArchetypesState&, swift::SILFunction&, swift::CanType, swift::SubstitutionMap) + 951
9  swift-frontend           0x0000000105934039 swift::MetatypeInst::create(swift::SILDebugLocation, swift::SILType, swift::SILFunction*, swift::SILOpenedArchetypesState&) + 201
10 swift-frontend           0x0000000105e486d8 swift::Lowering::SILGenFunction::emitCaptures(swift::SILLocation, swift::SILDeclRef, swift::Lowering::CaptureEmission, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&) + 824
11 swift-frontend           0x0000000105e499d7 swift::Lowering::SILGenFunction::emitClosureValue(swift::SILLocation, swift::SILDeclRef, swift::CanType, swift::SubstitutionMap) + 1079
12 swift-frontend           0x0000000105e406e7 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 295
13 swift-frontend           0x0000000105e341d5 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 133
14 swift-frontend           0x0000000105e2adf7 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 55
15 swift-frontend           0x0000000105deb958 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2008
16 swift-frontend           0x0000000105dda437 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 679
17 swift-frontend           0x0000000105dead23 (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 147
18 swift-frontend           0x0000000105df419d (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::Lowering::CalleeTypeInfo::ForeignInfo const&) && + 909
19 swift-frontend           0x0000000105df3969 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::Lowering::CalleeTypeInfo::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&) + 1561
20 swift-frontend           0x0000000105dde553 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2755
21 swift-frontend           0x0000000105ddc25f swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 1935
22 swift-frontend           0x0000000105e341bb swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 107
23 swift-frontend           0x0000000105e2b1a1 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 849
24 swift-frontend           0x0000000105dd0721 swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 321
25 swift-frontend           0x0000000105dd1077 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1943
26 swift-frontend           0x0000000105e97970 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&) + 128
27 swift-frontend           0x0000000105dd4ff3 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 403
28 swift-frontend           0x0000000105dd20c5 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 165
29 swift-frontend           0x0000000105737731 performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 545
30 swift-frontend           0x000000010572bdf4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4852
31 swift-frontend           0x000000010567c847 main + 519
32 libdyld.dylib            0x00007fff2045e621 start + 1
33 libdyld.dylib            0x000000000000000c start + 18446603339974711788
zsh: abort      ./swift ~/Desktop/test.swift
typesanitizer commented 3 years ago

@swift-ci create

own2pwn commented 2 years ago

Any update on this?

own2pwn commented 2 years ago

Maybe a regression in Swift 5.7

theblixguy commented 2 years ago

This never got fixed, so it still crashes.

own2pwn commented 2 years ago

This never got fixed, so it still crashes.

I'm sure this is a regression. Similar code was working fine in 5.4 or 5.5

AnthonyLatsis commented 2 years ago

This is not supposed to work though, we should diagnose an error instead. Dynamic Self (or Self?) in type context is only supported as the result type in methods and get-only subscripts, and as the type of a get-only computed property.

msklywenn commented 3 months ago

I have a similar bug but I'm not exactly sure if it's the same or not.

func Map<Source, Destination>(_ transform: @escaping (Source) -> Destination) -> any Sequence<Destination> {
        return []
}

for i in Map({$0 + 1}) {
        print(i)
}
error: compile command failed due to signal 6 (use -v to see invocation)
Unhandled coercion:
(type_variable_type id=2)
(struct_type decl=Swift.(file).Int)
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 Bug.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.5.sdk -color-diagnostics -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 Bug -disable-clang-spi -target-sdk-version 14.5 -target-sdk-name macosx14.5 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.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/6c/_9x490kd5n1bym6_4yw_2hqh0000gn/T/TemporaryDirectory.KsBRsO/Bug-1.o
1.  Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
2.  Compiling with the current language version
3.  While evaluating request TypeCheckSourceFileRequest(source_file "Bug.swift")
4.  While type-checking statement at [Bug.swift:5:1 - line:7:1] RangeText="for i in Map({$0 + 1}) {
    print(i)
"
5.  While type-checking statement at [Bug.swift:5:1 - line:7:1] RangeText="for i in Map({$0 + 1}) {
    print(i)
"
6.  While type-checking-for-each statement at [Bug.swift:5:1 - line:7:1] RangeText="for i in Map({$0 + 1}) {
    print(i)
"
7.  While type-checking-target starting at Bug.swift:5: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           0x0000000107f63f3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000107f630f8 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000107f64544 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x000000019f8ab584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000019f87ac20 pthread_kill + 288
5  libsystem_c.dylib        0x000000019f787a30 abort + 180
6  swift-frontend           0x00000001038c3224 (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 9076
7  swift-frontend           0x00000001038eb18c buildOpaqueElementConversion((anonymous namespace)::ExprRewriter&, swift::SourceRange, swift::Type, swift::Type, bool, swift::constraints::ConstraintLocatorBuilder, unsigned int) + 608
8  swift-frontend           0x00000001038ef468 (anonymous namespace)::ExprRewriter::coerceExistential(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 1860
9  swift-frontend           0x00000001038c2804 (anonymous namespace)::ExprRewriter::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 6484
10 swift-frontend           0x00000001038c0dd4 swift::constraints::Solution::coerceToType(swift::Expr*, swift::Type, swift::constraints::ConstraintLocator*) + 176
11 swift-frontend           0x00000001038eb748 applySolutionToInitialization(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget, swift::Expr*, std::__1::function<llvm::Optional<swift::constraints::SyntacticElementTarget> (swift::constraints::SyntacticElementTarget)>) + 764
12 swift-frontend           0x00000001038bfe88 (anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SyntacticElementTarget) + 5060
13 swift-frontend           0x00000001038ee028 llvm::Optional<swift::constraints::SyntacticElementTarget> llvm::function_ref<llvm::Optional<swift::constraints::SyntacticElementTarget> (swift::constraints::SyntacticElementTarget)>::callback_fn<(anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SyntacticElementTarget)::$_34>(long, swift::constraints::SyntacticElementTarget) + 76
14 swift-frontend           0x00000001038ec07c applySolutionToForEachStmt(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget, llvm::function_ref<llvm::Optional<swift::constraints::SyntacticElementTarget> (swift::constraints::SyntacticElementTarget)>) + 512
15 swift-frontend           0x00000001038bf358 (anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SyntacticElementTarget) + 2196
16 swift-frontend           0x00000001038be5d0 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget) + 6984
17 swift-frontend           0x0000000103b83b94 swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 660
18 swift-frontend           0x0000000103b85430 swift::TypeChecker::typeCheckForEachBinding(swift::DeclContext*, swift::ForEachStmt*) + 428
19 swift-frontend           0x0000000103c963f4 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 760
20 swift-frontend           0x0000000103c95fc4 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 316
21 swift-frontend           0x0000000103c91008 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) + 104
22 swift-frontend           0x0000000103c96224 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 296
23 swift-frontend           0x0000000103c93a6c bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 316
24 swift-frontend           0x0000000103c93c40 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 140
25 swift-frontend           0x0000000103ce0498 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 472
26 swift-frontend           0x0000000103ce6988 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 664
27 swift-frontend           0x0000000103ce0240 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 228
28 swift-frontend           0x0000000102a70854 swift::CompilerInstance::performSema() + 196
29 swift-frontend           0x0000000102865634 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1352
30 swift-frontend           0x00000001028636d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4968
31 swift-frontend           0x00000001027f2e8c swift::mainEntry(int, char const**) + 2612
32 dyld                     0x000000019f4f20e0 start + 2360
error: fatalError

Should I report this as a different bug?

The crash goes away if I store the result of the Map call into a variable and then pass that variable to the for loop.

AnthonyLatsis commented 3 months ago

@msklywenn Please open a new issue for this. Thanks.

msklywenn commented 3 months ago

Ok, done in https://github.com/apple/swift/issues/74545