Skip to content

Commit 32d7c84

Browse files
committed
handle nested let_value's when computing result domain
fixes #1218
1 parent e38f27a commit 32d7c84

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

include/stdexec/execution.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3571,8 +3571,11 @@ namespace stdexec {
35713571
using _Domain = __result_domain_t<_Set, _Child, _Fun, _Env, _Sched>;
35723572
if constexpr (__merror<_Domain>) {
35733573
return _Domain();
3574+
} else if constexpr (same_as<_Domain, dependent_domain>) {
3575+
using _Domain2 = __late_domain_of_t<_Child, _Env>;
3576+
return __make_sexpr<__let_t<_Set, _Domain2>>((_Fun&&) __fun, (_Child&&) __child);
35743577
} else {
3575-
static_assert(__none_of<_Domain, __none_such, dependent_domain>);
3578+
static_assert(!same_as<_Domain, __none_such>);
35763579
return __make_sexpr<__let_t<_Set, _Domain>>((_Fun&&) __fun, (_Child&&) __child);
35773580
}
35783581
}

test/stdexec/algos/adaptors/test_let_value.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,15 @@ namespace {
316316
| ex::let_value([](std::string& x) { return ex::just(x + ", world"); });
317317
wait_for_value(std::move(snd), std::string{"hallo"});
318318
}
319+
320+
TEST_CASE("let_value can nest", "[adaptors][let_value]") {
321+
auto work = ex::just(2) //
322+
| ex::let_value([](int x) { //
323+
return ex::just() //
324+
| ex::let_value([=] { //
325+
return ex::just(x);
326+
});
327+
});
328+
wait_for_value(std::move(work), 2);
329+
}
319330
}

0 commit comments

Comments
 (0)