Skip to content

[interop] Swift enum with more than one case and no associated values crash the compiler #64340

@augusto2112

Description

@augusto2112

Repro steps:

Modify test/Interop/SwiftToCxx/enums/swift-enum-implementation.swift to contain only the following:

public enum E {
    case foobar
    case baz
}

Modify test/Interop/SwiftToCxx/enums/swift-enum-implementation-execution.cpp to contain only the following:

int main() {
    #include <cassert>
    #include "enums.h"
    
    using namespace Enums;

    auto e = E::foobar();
    return  0;
}

Running swift-enum-implementation-execution.cpp, the test will crash with the following error:

/Users/augusto/Developer/swift/build/Ninja-RelWithDebInfoAssert+stdlib-RelWithDebInfo/swift-macosx-arm64/test-macosx-arm64/Interop/SwiftToCxx/enums/Output/swift-enum-implementation-execution.cpp.tmp/enums.h:676:39: error: no type named 'Hasher' in namespace 'swift'
  SWIFT_INLINE_THUNK void hash(swift::Hasher& hasher) const SWIFT_SYMBOL("s:5Enums1EO4hash4intoys6HasherVz_tF");
                               ~~~~~~~^
/Users/augusto/Developer/swift/build/Ninja-RelWithDebInfoAssert+stdlib-RelWithDebInfo/swift-macosx-arm64/test-macosx-arm64/Interop/SwiftToCxx/enums/Output/swift-enum-implementation-execution.cpp.tmp/enums.h:910:42: error: no type named 'Hasher' in namespace 'swift'
  SWIFT_INLINE_THUNK void E::hash(swift::Hasher& hasher) const {
                                  ~~~~~~~^
/Users/augusto/Developer/swift/build/Ninja-RelWithDebInfoAssert+stdlib-RelWithDebInfo/swift-macosx-arm64/test-macosx-arm64/Interop/SwiftToCxx/enums/Output/swift-enum-implementation-execution.cpp.tmp/enums.h:911:67: error: no member named '_impl_Hasher' in namespace 'swift::_impl'
  return _impl::$s5Enums1EO4hash4intoys6HasherVz_tF(swift::_impl::_impl_Hasher::getOpaquePointer(hasher), _impl::swift_interop_passDirect_Enums_uint8_t_0_1(_getOpaquePointer()));

Version:

Swift version 5.9-dev (LLVM 11017a372a2fcf3, Swift 57128dd0ee11e00)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.c++ interopFeature: Interoperability with C++compilerThe Swift compiler itselfenumFeature → type declarations: Swift enumeration declarationsswift 5.9swift to c++Feature → c++ interop: swift to c++triage neededThis issue needs more specific labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions