Open theblixguy opened 3 years ago
@swift-ci create
Any update on this?
This never got fixed, so it still crashes.
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
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.
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.
@msklywenn Please open a new issue for this. Thanks.
Ok, done in https://github.com/apple/swift/issues/74545
Environment
Swift version 5.4-dev (LLVM bd2476a8056e227, Swift 14c18531a3b3d95) Target: x86_64-apple-darwin20.3.0 OS: macOS Big Sur 11.2.3Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, CompilerCrash, SILGen, TypeChecker | |Assignee | None | |Priority | Medium | md5: 5d60f820e589fc287538e4bf6877aec7Issue Description:
The following code crashes in the CSApply:
If you remove the discard assignment, then it crashes in SIL: