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-8165] Compiler Crash in FailureDiagnosis for matching pattern with postfix operator #50697

Closed
rintaro mannequin opened this issue Jul 2, 2018 · 5 comments
Closed
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 type checker Area → compiler: Semantic analysis

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Jul 2, 2018

Previous ID SR-8165
Radar rdar://problem/41718486
Original Reporter @rintaro
Type Bug
Status Closed
Resolution Done
Environment

Current master:
Swift version 4.2-dev (LLVM d6832022e4, Clang b531f0b345, Swift 3f6e4600dd)
Target: x86_64-apple-darwin17.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @rintaro
Priority Medium

md5: adf7340a349aa1ec2a43dfbc809c4472

Issue Description:

postfix operator <<<
postfix func <<< <T>(x: T) -> Bool { }
func blah<T>(x: (T, T)) {
  switch x {
  case let (a, b)<<<:
    break
  }
}
Assertion failed: (!field.getType().isNull() && "Cannot get canonical type of un-typechecked TupleType!"), function computeCanonicalType, file /Users/rintaro/Repositories/swift-oss/swift/lib/AST/Type.cpp, line 1116.
0  swift                    0x00000001047d8a8a PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x00000001047d7e96 SignalHandler(int) + 966
2  libsystem_platform.dylib 0x00007fff5a51df5a _sigtramp + 26
3  libsystem_malloc.dylib   0x00007fff5a3b83bf szone_malloc_should_clear + 422
4  swift                    0x0000000101a4707d (anonymous namespace)::ExprRewriter::coerceCallArguments(swift::Expr*, swift::AnyFunctionType*, swift::ApplyExpr*, llvm::ArrayRef<swift::Identifier>, bool, swift::constraints::ConstraintLocatorBuilder) + 9773
5  swift                    0x0000000101a42c97 (anonymous namespace)::ExprRewriter::finishApply(swift::ApplyExpr*, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 4087
6  swift                    0x0000000101a63407 (anonymous namespace)::ExprRewriter::visitApplyExpr(swift::ApplyExpr*) + 199
7  swift                    0x0000000101a4e069 (anonymous namespace)::ExprWalker::walkToExprPost(swift::Expr*) + 25
8  swift                    0x0000000101ba75e1 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 2097
9  swift                    0x0000000101a80d09 (anonymous namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<TCCFlags, unsigned int>, swift::ExprTypeCheckListener*, bool) + 1561
10 swift                    0x0000000101a98b5a (anonymous namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*, swift::Type, swift::CalleeCandidateInfo const&, swift::OptionSet<TCCFlags, unsigned int>) + 5594
11 swift                    0x0000000101a91cba (anonymous namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 7226
12 swift                    0x0000000101a6fec6 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 70
13 swift                    0x0000000101aa337f swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 6207
14 swift                    0x0000000101ba6b8a swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 122
15 swift                    0x0000000101ba726c swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1212
16 swift                    0x0000000101baba52 swift::TypeChecker::typeCheckCondition(swift::Expr*&, swift::DeclContext*) + 178
17 swift                    0x0000000101bac689 swift::TypeChecker::typeCheckExprPattern(swift::ExprPattern*, swift::DeclContext*, swift::Type) + 1529
18 swift                    0x0000000101bf9603 swift::TypeChecker::coercePatternToType(swift::Pattern*&, swift::DeclContext*, swift::Type, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, swift::TypeLoc) + 1795
19 swift                    0x0000000101bf9173 swift::TypeChecker::coercePatternToType(swift::Pattern*&, swift::DeclContext*, swift::Type, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, swift::TypeLoc) + 627
20 swift                    0x0000000101c3c1c7 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 4087
21 swift                    0x0000000101c3e1ec swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 12316
22 swift                    0x0000000101c3a2ee swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 1294
23 swift                    0x0000000101c3fbd8 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 872
24 swift                    0x0000000101c65bd3 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2515
25 swift                    0x000000010189b88e swift::CompilerInstance::performSema() + 4238
26 swift                    0x0000000100a72bb1 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 737
27 swift                    0x0000000100a6f3d5 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7733
28 swift                    0x0000000100a18a68 main + 13144
29 libdyld.dylib            0x00007fff5a20f015 start + 1
Stack dump:
0.  Program arguments: /XcodeDev/Justice/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret test.swift -enable-objc-interop -sdk /XcodeDev/Justice/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name test 
1.  While type-checking 'blah(x:)' at test.swift:3:1
2.  While type-checking statement at [test.swift:3:25 - line:8:1] RangeText="{
  switch x {
  case let (a, b)<<<:
    break
  }
}"
3.  While type-checking statement at [test.swift:4:3 - line:7:3] RangeText="switch x {
  case let (a, b)<<<:
    break
  }"
4.  While type-checking pattern at [test.swift:5:12 - line:5:18] RangeText="(a, b)<"
5.  While type-checking expression at [test.swift:5:12 - line:5:18] RangeText="(a, b)<"
6.  While type-checking expression at [test.swift:5:12 - line:5:18] RangeText="(a, b)<"
Segmentation fault: 11
@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Jul 2, 2018

CC: @xedin

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Jul 2, 2018

Repro with stdlib type/operator:

func blah(x: (Int, Int)) {
  switch x {
  case let (a, b)...:
    break
  }
}

@xedin
Copy link
Member

xedin commented Jul 2, 2018

@swift-ci create

@xedin
Copy link
Member

xedin commented Feb 19, 2020

Looks like the diagnostic has been ported and crash/diagnostic is fixed in 11.4. @rintaro please verify, diagnostic is `error: binary operator '~=' cannot be applied to operands of type 'Bool' and '(T, T)'`

@rintaro
Copy link
Mannequin Author

rintaro mannequin commented Feb 19, 2020

Verified

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 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 crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants