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

Fix error_types in dematerialize sender #609

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jacksonwelles
Copy link

@jacksonwelles jacksonwelles commented Jun 6, 2024

Hiyo, I found what looks like a bug in the dematerialize sender.

The issue is here: #611

To summarize error_types of a sender created by dematerialize is usually an invalid type. For example the following code:

#include <unifex/dematerialize.hpp>
#include <unifex/just.hpp>

#include <unifex/materialize.hpp>
#include <type_traits>
#include <variant>

using namespace unifex;

using Sender = std::decay_t<decltype(dematerialize(materialize(just())))>;
using Errors = typename sender_traits<Sender>::template error_types<std::variant>;
int main() {}

(here on godbolt)
fails to compile and gives the error error: no type named 'type' in 'struct unifex::single_type<>'

When we use std::conditional_t to filter the source sender's value_types into ones that start with set_error, sometimes the false branch type isn't valid.

I think the easiest solution is to add a layer of indirection so that the template argument to tuple isn't evaluated when the condition is false, which I've done here.

After this the compiler complained about a missing ::type so I updated that and switched a ::type to _t for consistency.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants