Skip to content

[C++ Interop] generated header contains ambiguous overloads / redefinitions #87063

@tothambrus11

Description

@tothambrus11

Description

When enabling C++ interop in my module and using its generated header file from C++, the header appears to contain redefinition of functions.

Reproduction

CI Run (look at ubuntu): https://github.com/hylo-lang/hylo-new/actions/runs/21786807627/job/62859520288?pr=40

See the reproduction in this PR: https://github.com/hylo-lang/hylo-new/pull/41/changes

I attached the generated header file: FrontEnd-Swift.h.txt

In file included from /home/runner/work/hylo-new/hylo-new/Sources/LLVMEmitter/include/Example.cpp:1:
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:6985:53: error: functions that differ only in their return type cannot be overloaded
 6985 |   SWIFT_INLINE_THUNK swift::Optional<swift::String> getString() const SWIFT_SYMBOL("s:8FrontEnd10AnnotationV8ArgumentO6stringSSSgvp");
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:6965:36: note: previous declaration is here
 6965 |   SWIFT_INLINE_THUNK swift::String getString() const;
      |                      ~~~~~~~~~~~~~ ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:6986:50: error: functions that differ only in their return type cannot be overloaded
 6986 |   SWIFT_INLINE_THUNK swift::Optional<swift::Int> getNumber() const SWIFT_SYMBOL("s:8FrontEnd10AnnotationV8ArgumentO6numberSiSgvp");
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:6974:33: note: previous declaration is here
 6974 |   SWIFT_INLINE_THUNK swift::Int getNumber() const;
      |                      ~~~~~~~~~~ ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:7308:47: error: class member cannot be redeclared
 7308 |   static SWIFT_INLINE_THUNK AnySyntaxIdentity init(uint64_t value) SWIFT_SYMBOL("s:8FrontEnd17AnySyntaxIdentityV14integerLiteralACs6UInt64V_tcfc");
      |                                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:7298:47: note: previous declaration is here
 7298 |   static SWIFT_INLINE_THUNK AnySyntaxIdentity init(uint64_t bits) SWIFT_SYMBOL("s:8FrontEnd17AnySyntaxIdentityV4bitsACs6UInt64V_tcfc");
      |                                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:7465:45: error: class member cannot be redeclared
 7465 |   static SWIFT_INLINE_THUNK AnyTypeIdentity init(uint64_t value) SWIFT_SYMBOL("s:8FrontEnd15AnyTypeIdentityV14integerLiteralACs6UInt64V_tcfc");
      |                                             ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:7451:45: note: previous declaration is here
 7451 |   static SWIFT_INLINE_THUNK AnyTypeIdentity init(uint64_t bits) SWIFT_SYMBOL("s:8FrontEnd15AnyTypeIdentityV4bitsACs6UInt64V_tcfc");
      |                                             ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:14076:69: error: class member cannot be redeclared
 14076 |   static SWIFT_INLINE_THUNK swift::Optional<FloatingPointPredicate> init(const swift::String& description) SWIFT_SYMBOL("s:8FrontEnd22FloatingPointPredicateOyACSgSScfc");
       |                                                                     ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:14074:69: note: previous declaration is here
 14074 |   static SWIFT_INLINE_THUNK swift::Optional<FloatingPointPredicate> init(const swift::String& rawValue) SWIFT_SYMBOL("s:8FrontEnd22FloatingPointPredicateO8rawValueACSgSS_tcfc");
       |                                                                     ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:19990:63: error: class member cannot be redeclared
 19990 |   static SWIFT_INLINE_THUNK swift::Optional<IntegerPredicate> init(const swift::String& description) SWIFT_SYMBOL("s:8FrontEnd16IntegerPredicateOyACSgSScfc");
       |                                                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:19988:63: note: previous declaration is here
 19988 |   static SWIFT_INLINE_THUNK swift::Optional<IntegerPredicate> init(const swift::String& rawValue) SWIFT_SYMBOL("s:8FrontEnd16IntegerPredicateO8rawValueACSgSS_tcfc");
       |                                                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:26103:40: error: class member cannot be redeclared
 26103 |   static SWIFT_INLINE_THUNK SourceFile init(const swift::String& contents) SWIFT_SYMBOL("s:8FrontEnd10SourceFileV13stringLiteralACSS_tcfc");
       |                                        ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:26084:40: note: previous declaration is here
 26084 |   static SWIFT_INLINE_THUNK SourceFile init(const swift::String& contents) SWIFT_SYMBOL("s:8FrontEnd10SourceFileV8contentsACSS_tcfc");
       |                                        ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32247:83: error: return type of out-of-line definition of 'FrontEnd::__AnnotationNested::Argument::getString' differs from that in the declaration
 32247 |   SWIFT_INLINE_THUNK swift::Optional<swift::String> __AnnotationNested::Argument::getString() const {
       |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32220:66: note: previous definition is here
 32220 |   SWIFT_INLINE_THUNK swift::String __AnnotationNested::Argument::getString() const {
       |                      ~~~~~~~~~~~~~                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32252:80: error: return type of out-of-line definition of 'FrontEnd::__AnnotationNested::Argument::getNumber' differs from that in the declaration
 32252 |   SWIFT_INLINE_THUNK swift::Optional<swift::Int> __AnnotationNested::Argument::getNumber() const {
       |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32238:63: note: previous definition is here
 32238 |   SWIFT_INLINE_THUNK swift::Int __AnnotationNested::Argument::getNumber() const {
       |                      ~~~~~~~~~~                               ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32315:59: error: redefinition of 'init'
 32315 |   SWIFT_INLINE_THUNK AnySyntaxIdentity AnySyntaxIdentity::init(uint64_t value) {
       |                                                           ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32281:59: note: previous definition is here
 32281 |   SWIFT_INLINE_THUNK AnySyntaxIdentity AnySyntaxIdentity::init(uint64_t bits) {
       |                                                           ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32380:55: error: redefinition of 'init'
 32380 |   SWIFT_INLINE_THUNK AnyTypeIdentity AnyTypeIdentity::init(uint64_t value) {
       |                                                       ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:32328:55: note: previous definition is here
 32328 |   SWIFT_INLINE_THUNK AnyTypeIdentity AnyTypeIdentity::init(uint64_t bits) {
       |                                                       ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:33706:86: error: redefinition of 'init'
 33706 |   SWIFT_INLINE_THUNK swift::Optional<FloatingPointPredicate> FloatingPointPredicate::init(const swift::String& description) {
       |                                                                                      ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:33693:86: note: previous definition is here
 33693 |   SWIFT_INLINE_THUNK swift::Optional<FloatingPointPredicate> FloatingPointPredicate::init(const swift::String& rawValue) {
       |                                                                                      ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:34692:74: error: redefinition of 'init'
 34692 |   SWIFT_INLINE_THUNK swift::Optional<IntegerPredicate> IntegerPredicate::init(const swift::String& description) {
       |                                                                          ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:34679:74: note: previous definition is here
 34679 |   SWIFT_INLINE_THUNK swift::Optional<IntegerPredicate> IntegerPredicate::init(const swift::String& rawValue) {
       |                                                                          ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:36217:45: error: redefinition of 'init'
 36217 |   SWIFT_INLINE_THUNK SourceFile SourceFile::init(const swift::String& contents) {
       |                                             ^
/home/runner/work/hylo-new/hylo-new/.build/x86_64-unknown-linux-gnu/debug/FrontEnd.build/include/FrontEnd-Swift.h:36160:45: note: previous definition is here
 36160 |   SWIFT_INLINE_THUNK SourceFile SourceFile::init(const swift::String& contents) {
       |                                             ^
14 errors generated.
error: fatalError

Expected behavior

No redefined functions.

Environment

Swift version 6.2.3 (swift-6.2.3-RELEASE)
Target: x86_64-unknown-linux-gnu

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage neededThis issue needs more specific labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions