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

exec::finally() doesn't include error/stopped signatures from final-sender in completion-signatures #1334

Closed
lewissbaker opened this issue May 19, 2024 · 0 comments · Fixed by #1336
Labels
bug Something isn't working

Comments

@lewissbaker
Copy link
Contributor

The following code-snippet fails to compile because let_error() computes the variant to hold any potential error produced by finally, but the completion-signatures listed by finally do not include the error-types of the final-sender, despite the finally-algorithm forwarding through these errors.

https://godbolt.org/z/av9rhrbPe

#include <stdexec/execution.hpp>
#include <exec/finally.hpp>

#include <cstdio>

struct X {
    X() : value(0) { std::puts("X::X()"); }
    X(X&& o) noexcept : value(o.value) { std::puts("X::X(X&&)"); }
    X(const X& o) noexcept : value(o.value)  { std::puts("X::X(const X&)"); }
    ~X() { std::puts("X::~X()"); value = -1; }
    int value;
};

int main() {
    auto result = stdexec::sync_wait(
        stdexec::let_error(
            exec::finally(
                stdexec::just(),
                stdexec::just_error(X{})),
            [](const auto& x) noexcept {
                if constexpr (std::same_as<const X&, decltype(x)>) {
                    std::printf("caught X(value=%i)\n", x.value);
                } else {
                    std::printf("caught an exception_ptr\n");
                }
                return stdexec::just();
            }));
}
@ericniebler ericniebler added the bug Something isn't working label May 20, 2024
@ericniebler ericniebler linked a pull request May 20, 2024 that will close this issue
ericniebler added a commit that referenced this issue May 20, 2024
fix completion signatures of `exec::finally`, fixes #1334
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants