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-12746] Assertion failure when type-checking patterns with ambiguous cases #55191

Closed
typesanitizer opened this issue May 7, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@typesanitizer
Copy link

Previous ID SR-12746
Radar rdar://problem/62961009
Original Reporter @typesanitizer
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 35c9d952abcdef21cf96c389ddaf99d2

is duplicated by:

  • SR-12229 Assertion failure when trying to pattern match enum cases with same base name

Issue Description:

 enum X {
    case a(())
    case a(_z: ())
}
func g(_ x: X) {
    switch x {
        case .a: ()
    }
}

This triggers an assertion failure on master @ ad00350.

Assertion failed: (!foundElement && "ambiguity in enum case name lookup?!"), function filterForEnumElement, file /Users/varun/foss-swift/swift/lib/Sema/TypeCheckPattern.cpp, line 98.
Stack dump:
0.      Program arguments: /Users/varun/foss-swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file /Users/varun/Tmp.swift -target x86_64-apple-darwin19.4.0 -enable-objc-interop -color-diagnostics -module-name Tmp -o /var/folders/9t/dn6p4v392nb8c8cwxfyxc84c0000gn/T/Tmp-90f416.o
1.      Swift version 5.3-dev (LLVM 6c12ce6117, Swift ad003502db)
2.      While evaluating request TypeCheckSourceFileRequest(source_file "/Users/varun/Tmp.swift")
3.      While evaluating request TypeCheckFunctionBodyUntilRequest(Tmp.(file).g@/Users/varun/Tmp.swift:6:6, )
4.      While type-checking statement at [/Users/varun/Tmp.swift:6:16 - line:10:1] RangeText="{
    switch x {
        case .a: ()
    }
"
5.      While type-checking statement at [/Users/varun/Tmp.swift:7:5 - line:9:5] RangeText="switch x {
        case .a: ()
    "
0  swift                    0x00000001074ab725 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001074aa975 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001074abcf6 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff693175fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338751314464
5  libsystem_c.dylib        0x00007fff691ed808 abort + 120
6  libsystem_c.dylib        0x00007fff691ecac6 err + 0
7  swift                    0x00000001078b9011 filterForEnumElement(swift::DeclContext*, swift::SourceLoc, bool, swift::LookupResult) (.cold.9) + 33
8  swift                    0x0000000104032a52 filterForEnumElement(swift::DeclContext*, swift::SourceLoc, bool, swift::LookupResult) + 706
9  swift                    0x00000001040321af lookupEnumMemberElement(swift::DeclContext*, swift::Type, swift::DeclNameRef, swift::SourceLoc) + 191
10 swift                    0x000000010402f1c7 swift::TypeChecker::coercePatternToType(swift::ContextualPattern, swift::Type, swift::TypeResolutionOptions) + 3479

It should probably issue an error about the ambiguity instead.

@typesanitizer
Copy link
Author

@swift-ci create

@theblixguy
Copy link
Collaborator

I think this is the same as SR-12229

@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