Skip to content

[interop] C++ function returning NonCopyable type returns Never in Swift and is callable #64401

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

Closed
Tracked by #65808
hyp opened this issue Mar 15, 2023 · 6 comments · Fixed by #65056 or #67234
Closed
Tracked by #65808

[interop] C++ function returning NonCopyable type returns Never in Swift and is callable #64401

hyp opened this issue Mar 15, 2023 · 6 comments · Fixed by #65056 or #67234
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift clang importer Area → compiler: The clang importer compiler The Swift compiler itself swift 5.9 unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@hyp
Copy link
Contributor

hyp commented Mar 15, 2023

This code:

struct NonCopyable {
    NonCopyable(const NonCopyable &) = delete;
    
    int x;
};

NonCopyable returnsNoncopyable();

Produces callable returnsNoncopyable function in Swift module interface that returns Never:

func returnsNoncopyable() -> Never

This function is callable, and doesn't result in an error unless the return value is attempted to be used.

@hyp hyp added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. c++ interop Feature: Interoperability with C++ triage needed This issue needs more specific labels labels Mar 15, 2023
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself c++ to swift Feature → c++ interop: c++ to swift copy constructors swift 5.9 unexpected behavior Bug: Unexpected behavior or incorrect output and removed triage needed This issue needs more specific labels labels Mar 16, 2023
@Rajveer100
Copy link
Contributor

@hyp Could you give a hint on how one would go about this?

@Rajveer100
Copy link
Contributor

@AnthonyLatsis Are there any resources I can go through to solve this?

@AnthonyLatsis
Copy link
Collaborator

My best guess would be that this is an issue with ClangImporter. My interoperability kung fu is pretty lame though, so take this with a grain of salt. That aside, C++ interop is an experimental feature. If I were to poke at this, I would skim through the manifesto first.

@Rajveer100
Copy link
Contributor

Well, ok!
@egorzhdan What's your take on this! Please let me know!

@hyp
Copy link
Contributor Author

hyp commented May 5, 2023

Sorry for delay, I already have a PR that addresses on this issue: #65105 . Not yet merged to 5.9 though

@hyp
Copy link
Contributor Author

hyp commented Jul 11, 2023

Will work around it in a different way

hyp added a commit to hyp/swift that referenced this issue Jul 11, 2023
…ailable

This prevents users from calling functions with unsupported or unavailable return types. This ensures that users don't for example call a function that returns a non-copyable and non-movable type

Fixes swiftlang#64401
hyp added a commit to hyp/swift that referenced this issue Jul 11, 2023
…ailable

This prevents users from calling functions with unsupported or unavailable return types. This ensures that users don't for example call a function that returns a non-copyable and non-movable type

Fixes swiftlang#64401
hyp added a commit to hyp/swift that referenced this issue Jul 12, 2023
…ailable

This prevents users from calling functions with unsupported or unavailable return types. This ensures that users don't for example call a function that returns a non-copyable and non-movable type

Fixes swiftlang#64401
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. c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift clang importer Area → compiler: The clang importer compiler The Swift compiler itself swift 5.9 unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
3 participants