Skip to content

Typechecking crashes when enum contains a duplicated string raw value #63829

@tayloraswift

Description

@tayloraswift
struct A
{
    enum CodingKeys:String
    {
        case a
        case b
        case b
    }
}

crashes with

sourcekit-lsp: /home/build-user/swift/lib/Sema/TypeCheckDecl.cpp:1340: evaluator::SideEffect swift::EnumRawValuesRequest::evaluate(swift::Evaluator &, swift::EnumDecl *, swift::TypeResolutionStage) const: Assertion `lastExplicitValueElt && "should not be able to have non-unique raw values when " "relying on autoincrement"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	While evaluating request TypeCheckSourceFileRequest(source_file "/swift/swift-mongodb/crash.0.swift")
1.	While type-checking 'A' (at /swift/swift-mongodb/crash.0.swift:1:1)
2.	While type-checking 'CodingKeys' (at /swift/swift-mongodb/crash.0.swift:3:5)
3.	While type-checking 'a' (at /swift/swift-mongodb/crash.0.swift:5:14)
4.	While evaluating request EnumRawValuesRequest(main.(file).A.CodingKeys@/swift/swift-mongodb/crash.0.swift:3:10, interface)
[Error - 3:14:02 AM] Request textDocument/codeAction failed.

on swift-5.8-DEVELOPMENT-SNAPSHOT-2023-02-09-a . (amazon linux2 nightly docker container)

Metadata

Metadata

Assignees

Labels

StringArea → standard library: The `String` typebugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwaredeclarationsFeature: declarationsenumFeature → type declarations: Swift enumeration declarationsenum casesFeature → enums: Enum casesoverloadingFeature: Overloading symbol namesraw valuesFeature → enums → enum cases: Inline raw valuesstandard libraryArea: Standard library umbrellaswift 5.9type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions