Skip to content

Commit

Permalink
handle nested let_value's when computing result domain
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed Jan 22, 2024
1 parent e38f27a commit 32d7c84
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
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);
}
}

0 comments on commit 32d7c84

Please sign in to comment.