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

[SR-10561] Compiler crash Type Checker #52961

Closed
swift-ci opened this issue Apr 26, 2019 · 1 comment
Closed

[SR-10561] Compiler crash Type Checker #52961

swift-ci opened this issue Apr 26, 2019 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-10561
Radar None
Original Reporter DanielM (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode 10.2.1

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: ef911e8e06d4c2de34c752e4e871048e

duplicates:

Issue Description:

First version compiles.

func foo() {


  let bar: (String) -> Date? = {
    let baz: [Int] = $0.split(
      separator: ".", maxSplits: 2, omittingEmptySubsequences: true
      ).map(String.init).compactMap(Int.init)
    
     return nil
  }  
}

Removing ".map(String.init)" and the compiler will crash.

import Foundation

func foo() {
  
  let bar: (String) -> Date? = {
    let baz: [Int] = $0.split(
      separator: ".", maxSplits: 2, omittingEmptySubsequences: true
      ).compactMap(Int.init)
    
     return nil
  }
  
}
7.  While type-checking expression at [/Users/daniel/Desktop/Crash/Crash/main.swift:14:22 - line:16:28] RangeText="$0.split(
      separator: ".", maxSplits: 2, omittingEmptySubsequences: true
      ).compactMap(Int.init"
0  swift                    0x000000010a97dee3 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010a97d6bc SignalHandler(int) + 348
2  libsystem_platform.dylib 0x00007fff59970b5d _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffee94ace70 _sigtramp + 2410922800
4  swift                    0x0000000107975016 swift::constraints::RequirementFailure::getRequirementDC() const + 22
5  swift                    0x00000001079745a5 swift::constraints::RequirementFailure::diagnoseAsError() + 69
6  swift                    0x00000001079708e4 swift::constraints::MissingConformance::diagnose(swift::Expr*, bool) const + 500
7  swift                    0x00000001078a2424 swift::Expr* llvm::function_ref<swift::Expr* (swift::Expr*)>::callback_fn<swift::constraints::ConstraintSystem::applySolutionFixes(swift::Expr*, swift::constraints::Solution const&)::$_11>(long, swift::Expr*) + 228
8  swift                    0x0000000107dd7b2e swift::Expr::forEachChildExpr(llvm::function_ref<swift::Expr* (swift::Expr*)>)::ChildWalker::walkToExprPre(swift::Expr*) + 14
9  swift                    0x0000000107d83ced swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 205
10 swift                    0x0000000107d87b23 (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 211
11 swift                    0x0000000107a39bac swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 2716
12 swift                    0x0000000107a3d29e swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 350
13 swift                    0x0000000107a3da2c swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 348
14 swift                    0x0000000107a4a90f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 6687
15 swift                    0x0000000107adbe88 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 22632
16 swift                    0x0000000107ad65c1 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 129
17 swift                    0x0000000107adea73 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 499
18 swift                    0x0000000107a3a00b swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 3835
19 swift                    0x0000000107a3d29e swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, bool) + 350
20 swift                    0x0000000107a3da2c swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) + 348
21 swift                    0x0000000107a4a90f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 6687
22 swift                    0x0000000107adbe88 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 22632
23 swift                    0x0000000107ad65c1 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 129
24 swift                    0x0000000107ad5602 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 770
25 swift                    0x0000000107add82e swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 558
26 swift                    0x0000000107af9d1e swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1678
27 swift                    0x00000001072d8276 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 4614
28 swift                    0x00000001067d6546 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 838
29 swift                    0x00000001067d292e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6862
30 swift                    0x00000001067709ce main + 1246
31 libdyld.dylib            0x00007fff5978b3d5 start + 1
error: Segmentation fault: 11
@theblixguy
Copy link
Collaborator

This no longer crashes on Swift 5.1 and diagnoses as expected.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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
Projects
None yet
Development

No branches or pull requests

2 participants