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-7409] Multiple '@unknown' for single 'switch' hits assertion #49952

Closed
rintaro mannequin opened this issue Apr 11, 2018 · 2 comments
Closed

[SR-7409] Multiple '@unknown' for single 'switch' hits assertion #49952

rintaro mannequin opened this issue Apr 11, 2018 · 2 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

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Apr 11, 2018

Previous ID SR-7409
Radar None
Original Reporter @rintaro
Type Bug
Status Resolved
Resolution Done
Environment

master on 2018/04/11 (44531db)

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

md5: 172af46baf726d067ae387ccb14e9329

Issue Description:

$ cat test.swift
enum Whatever { case Thing }
func test(x: Whatever) {
  switch x {
    case .Thing:
      break
    @unknown case _:
      break
    @unknown case _:
      break
  }
}
$ ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift test.swift
test.swift:6:14: error: '@unknown' can only be applied to the last case in a switch
    @unknown case _:
             ^
Assertion failed: (unknownCase == nullptr), function checkExhaustiveness, file /Users/rintaro/Repositories/swift-oss/swift/lib/Sema/TypeCheckSwitchStmt.cpp, line 1219.
0  swift                    0x0000000113831898 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift                    0x0000000113831f26 SignalHandler(int) + 422
2  libsystem_platform.dylib 0x00007fff602e8f5a _sigtramp + 26
3  swift                    0x0000000114b970d0 cmark_strbuf__initbuf + 113003
4  libsystem_c.dylib        0x00007fff600861ae abort + 127
5  libsystem_c.dylib        0x00007fff6004e1ac basename_r + 0
6  swift                    0x0000000110d876f3 swift::TypeChecker::checkSwitchExhaustiveness(swift::SwitchStmt const*, swift::DeclContext const*, bool) + 6595
7  swift                    0x0000000110d8437f (anonymous namespace)::StmtChecker::visitSwitchStmt(swift::SwitchStmt*) + 3215
8  swift                    0x0000000110d81d6c swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 204
9  swift                    0x0000000110d801b8 swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 328
10 swift                    0x0000000110d80e71 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 449
11 swift                    0x0000000110da6065 typeCheckFunctionsAndExternalDecls(swift::SourceFile&, swift::TypeChecker&) + 261
12 swift                    0x0000000110da6ff8 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int) + 1816
13 swift                    0x00000001109dfd90 swift::CompilerInstance::parseAndTypeCheckMainFile(swift::PersistentParserState&, swift::DelayedParsingCallbacks*, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>) + 416
14 swift                    0x00000001109dea52 swift::CompilerInstance::parseAndCheckTypes(swift::CompilerInstance::ImplicitImports const&) + 626
15 swift                    0x00000001109de3b2 swift::CompilerInstance::performSema() + 466
16 swift                    0x000000010fe1bb90 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1904
17 swift                    0x000000010fe1a40e swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3310
18 swift                    0x000000010fdd8863 main + 2051
19 libdyld.dylib            0x00007fff5ffda015 start + 1
20 libdyld.dylib            0x000000000000000a start + 2684510198
Stack dump:
0.  Program arguments: /Users/rintaro/Repositories/swift-oss/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift -frontend -interpret test.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -color-diagnostics -module-name test 
1.  While type-checking 'test(x:)' at test.swift:2:1
Abort trap: 6
@belkadan
Copy link
Contributor

Oops, didn't think it would get to the exhaustiveness checking part. Thanks!

@belkadan
Copy link
Contributor

#15889

@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
Projects
None yet
Development

No branches or pull requests

2 participants