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

Unable to use std::chrono clocks via Cxx interop #72737

Open
karwa opened this issue Mar 31, 2024 · 0 comments
Open

Unable to use std::chrono clocks via Cxx interop #72737

karwa opened this issue Mar 31, 2024 · 0 comments
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 compiler The Swift compiler in itself swift 5.10 unexpected error Bug: Unexpected error

Comments

@karwa
Copy link
Collaborator

karwa commented Mar 31, 2024

Description

Compiler complains that the result of .now() is ambiguous without a type annotation. It shouldn't be ambiguous, and I was unable to find any incantation which would satisfy the compiler.

Reproduction

import CxxStdlib

let n = std.chrono.steady_clock.now()
//      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
// <source>:3:33: error: type of expression is ambiguous without a type annotation

(Build with -cxx-interoperability-mode=default)

Even with a type annotation:

let n: std.chrono.steady_clock.time_point = std.chrono.steady_clock.now()
//                                          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
// <source>:3:69: error: type of expression is ambiguous without a type annotation

It knows what the underlying type of steady_clock.time_point is, though:

image

Expected behavior

Expect it to work, even without a type annotation.

Environment

Swift version 5.10-dev (LLVM 5dc9d563e5a6cd2, Swift 9bfe759)
Target: x86_64-unknown-linux-gnu

Additional information

Godbolt

@karwa karwa added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Mar 31, 2024
@AnthonyLatsis AnthonyLatsis added c++ interop Feature: Interoperability with C++ c++ to swift Feature → c++ interop: c++ to swift compiler The Swift compiler in itself unexpected error Bug: Unexpected error swift 5.10 and removed triage needed This issue needs more specific labels labels Apr 1, 2024
@egorzhdan egorzhdan self-assigned this Apr 17, 2024
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 compiler The Swift compiler in itself swift 5.10 unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

3 participants