Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

handle nested let_value's when computing result domain #1219

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/stdexec/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3571,8 +3571,11 @@ namespace stdexec {
using _Domain = __result_domain_t<_Set, _Child, _Fun, _Env, _Sched>;
if constexpr (__merror<_Domain>) {
return _Domain();
} else if constexpr (same_as<_Domain, dependent_domain>) {
using _Domain2 = __late_domain_of_t<_Child, _Env>;
return __make_sexpr<__let_t<_Set, _Domain2>>((_Fun&&) __fun, (_Child&&) __child);
} else {
static_assert(__none_of<_Domain, __none_such, dependent_domain>);
static_assert(!same_as<_Domain, __none_such>);
return __make_sexpr<__let_t<_Set, _Domain>>((_Fun&&) __fun, (_Child&&) __child);
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/stdexec/algos/adaptors/test_let_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,15 @@ namespace {
| ex::let_value([](std::string& x) { return ex::just(x + ", world"); });
wait_for_value(std::move(snd), std::string{"hallo"});
}

TEST_CASE("let_value can nest", "[adaptors][let_value]") {
auto work = ex::just(2) //
| ex::let_value([](int x) { //
return ex::just() //
| ex::let_value([=] { //
return ex::just(x);
});
});
wait_for_value(std::move(work), 2);
}
}