From 8d7f36d2589b073dab4356d6a08020579470a6bc Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Fri, 31 Oct 2025 16:27:51 +0300 Subject: [PATCH 1/5] solve some runtime-light issues --- runtime-light/coroutine/detail/when-any.h | 12 ++++-- runtime-light/coroutine/io-scheduler.h | 39 ++++++++++++------- runtime-light/runtime-light.cmake | 1 - .../diagnostics}/php-assert.cpp | 0 .../operators}/null_coalesce.h | 0 runtime-light/stdlib/stdlib.cmake | 1 + runtime-light/stdlib/string/regex-state.h | 4 +- runtime-light/tl/tl-core.h | 6 +-- .../{utils => type-traits}/concepts.h | 4 ++ runtime-light/type-traits/functions.h | 25 ++++++++++++ runtime-light/utils/utils.cmake | 1 - 11 files changed, 69 insertions(+), 24 deletions(-) rename runtime-light/{utils => stdlib/diagnostics}/php-assert.cpp (100%) rename runtime-light/{utils => stdlib/operators}/null_coalesce.h (100%) rename runtime-light/{utils => type-traits}/concepts.h (88%) create mode 100644 runtime-light/type-traits/functions.h delete mode 100644 runtime-light/utils/utils.cmake diff --git a/runtime-light/coroutine/detail/when-any.h b/runtime-light/coroutine/detail/when-any.h index 085c1f3200..2c3bc7c7b4 100644 --- a/runtime-light/coroutine/detail/when-any.h +++ b/runtime-light/coroutine/detail/when-any.h @@ -16,6 +16,7 @@ #include "runtime-light/coroutine/type-traits.h" #include "runtime-light/coroutine/void-value.h" #include "runtime-light/stdlib/diagnostics/logs.h" +#include "runtime-light/type-traits/functions.h" namespace kphp::coro::detail::when_any { @@ -120,7 +121,9 @@ class when_any_ready_awaitable> { const auto task_result_processor{[&result = m_awaitable.m_result](auto&& task) noexcept { if (auto task_result{std::forward(task).result()}; !result.has_value() && task_result.has_value()) { - result = std::move(task_result); + using result_variant_type = std::remove_cvref::type::value_type; + using task_result_type = decltype(task_result)::value_type; + result = result_variant_type(std::in_place_index()>, *std::move(task_result)); } }}; std::apply([&task_result_processor](auto&&... tasks) noexcept { (std::invoke(task_result_processor, std::forward(tasks)), ...); }, @@ -290,8 +293,11 @@ class when_any_task { template auto make_when_any_task(awaitable_type awaitable) noexcept -> when_any_task::awaiter_return_type> { - co_yield co_await std::move(awaitable); - co_return; + if constexpr (std::is_void_v::awaiter_return_type>) { + co_await std::move(awaitable); + } else { + co_yield co_await std::move(awaitable); + } } } // namespace kphp::coro::detail::when_any diff --git a/runtime-light/coroutine/io-scheduler.h b/runtime-light/coroutine/io-scheduler.h index 241c518014..8adf8a7e09 100644 --- a/runtime-light/coroutine/io-scheduler.h +++ b/runtime-light/coroutine/io-scheduler.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -63,11 +64,11 @@ class io_scheduler { auto process_accept(k2::descriptor descriptor) noexcept -> void; auto update_timer() noexcept -> void; - [[nodiscard]] auto add_timer_token(k2::TimePoint time_point, - kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator; + [[nodiscard]] auto add_timer_token(k2::TimePoint time_point, kphp::coro::detail::poll_info& poll_info) noexcept + -> kphp::coro::detail::poll_info::timed_events::iterator; template - [[nodiscard]] auto add_timer_token(std::chrono::duration timeout, - kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator; + [[nodiscard]] auto add_timer_token(std::chrono::duration timeout, kphp::coro::detail::poll_info& poll_info) noexcept + -> kphp::coro::detail::poll_info::timed_events::iterator; auto remove_timer_token(kphp::coro::detail::poll_info::timed_events::iterator pos) noexcept -> void; public: @@ -161,8 +162,8 @@ class io_scheduler { * @param timeout Maximum duration to wait for the event (0 means no timeout). * @return A task that yields the poll status when completed. */ - [[nodiscard]] auto poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, - std::chrono::nanoseconds timeout = std::chrono::nanoseconds{0}) noexcept -> kphp::coro::task; + [[nodiscard]] auto poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, std::chrono::nanoseconds timeout = std::chrono::nanoseconds{0}) noexcept + -> kphp::coro::task; /** * @brief Accepts an incoming connection with optional timeout. @@ -329,8 +330,8 @@ inline auto io_scheduler::update_timer() noexcept -> void { } } -inline auto io_scheduler::add_timer_token(k2::TimePoint time_point, - kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator { +inline auto io_scheduler::add_timer_token(k2::TimePoint time_point, kphp::coro::detail::poll_info& poll_info) noexcept + -> kphp::coro::detail::poll_info::timed_events::iterator { const auto pos{m_timed_events.emplace(time_point, poll_info)}; if (pos == m_timed_events.begin()) { update_timer(); @@ -339,8 +340,8 @@ inline auto io_scheduler::add_timer_token(k2::TimePoint time_point, } template -auto io_scheduler::add_timer_token(std::chrono::duration timeout, - kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator { +auto io_scheduler::add_timer_token(std::chrono::duration timeout, kphp::coro::detail::poll_info& poll_info) noexcept + -> kphp::coro::detail::poll_info::timed_events::iterator { k2::TimePoint time_point{}; k2::instant(std::addressof(time_point)); time_point.time_point_ns += std::chrono::duration_cast(timeout).count(); @@ -463,13 +464,23 @@ auto io_scheduler::schedule(coroutine_type coroutine, std::chrono::duration::return_type; if (timeout <= std::chrono::duration{0}) [[unlikely]] { - co_return std::expected{co_await schedule(std::move(coroutine))}; + if constexpr (std::is_void_v) { + co_await schedule(std::move(coroutine)); + co_return std::expected{}; + } else { + co_return std::expected{co_await schedule(std::move(coroutine))}; + } } auto result{co_await kphp::coro::when_any(std::move(coroutine), make_timeout_task(timeout))}; if (std::holds_alternative(result)) [[unlikely]] { co_return std::unexpected{std::move(std::get<1>(result))}; } - co_return std::expected{std::move(std::get<0>(result))}; + + if constexpr (std::is_void_v) { + co_return std::expected{}; + } else { + co_return std::expected{std::move(std::get<0>(result))}; + } } template @@ -494,8 +505,8 @@ auto io_scheduler::yield_for(std::chrono::duration amount co_await schedule_after(amount); } -inline auto io_scheduler::poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, - std::chrono::nanoseconds timeout) noexcept -> kphp::coro::task { +inline auto io_scheduler::poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, std::chrono::nanoseconds timeout) noexcept + -> kphp::coro::task { k2::StreamStatus stream_status{}; k2::stream_status(descriptor, std::addressof(stream_status)); if (stream_status.libc_errno != k2::errno_ok) [[unlikely]] { diff --git a/runtime-light/runtime-light.cmake b/runtime-light/runtime-light.cmake index 3cc64e6e03..cbb74d4d38 100644 --- a/runtime-light/runtime-light.cmake +++ b/runtime-light/runtime-light.cmake @@ -22,7 +22,6 @@ include(${RUNTIME_LIGHT_DIR}/coroutine/coroutine.cmake) include(${RUNTIME_LIGHT_DIR}/server/server.cmake) include(${RUNTIME_LIGHT_DIR}/stdlib/stdlib.cmake) include(${RUNTIME_LIGHT_DIR}/tl/tl.cmake) -include(${RUNTIME_LIGHT_DIR}/utils/utils.cmake) include(${RUNTIME_LIGHT_DIR}/state/state.cmake) include(${RUNTIME_LIGHT_DIR}/memory-resource-impl/memory-resource-impl.cmake) diff --git a/runtime-light/utils/php-assert.cpp b/runtime-light/stdlib/diagnostics/php-assert.cpp similarity index 100% rename from runtime-light/utils/php-assert.cpp rename to runtime-light/stdlib/diagnostics/php-assert.cpp diff --git a/runtime-light/utils/null_coalesce.h b/runtime-light/stdlib/operators/null_coalesce.h similarity index 100% rename from runtime-light/utils/null_coalesce.h rename to runtime-light/stdlib/operators/null_coalesce.h diff --git a/runtime-light/stdlib/stdlib.cmake b/runtime-light/stdlib/stdlib.cmake index a176dac8f5..22ceaece1f 100644 --- a/runtime-light/stdlib/stdlib.cmake +++ b/runtime-light/stdlib/stdlib.cmake @@ -8,6 +8,7 @@ prepend( diagnostics/backtrace.cpp diagnostics/contextual-logger.cpp diagnostics/error-handling-state.cpp + diagnostics/php-assert.cpp file/resource.cpp fork/fork-state.cpp fork/wait-queue-state.cpp diff --git a/runtime-light/stdlib/string/regex-state.h b/runtime-light/stdlib/string/regex-state.h index d7ebee625d..50b43312c8 100644 --- a/runtime-light/stdlib/string/regex-state.h +++ b/runtime-light/stdlib/string/regex-state.h @@ -11,10 +11,10 @@ #include "runtime-common/core/allocator/script-allocator.h" #include "runtime-common/core/std/containers.h" #include "runtime-light/stdlib/string/regex-include.h" -#include "runtime-light/utils/concepts.h" +#include "runtime-light/type-traits/concepts.h" struct RegexInstanceState final : private vk::not_copyable { - template + template using unordered_map = kphp::stl::unordered_map; static constexpr size_t MAX_SUBPATTERNS_COUNT = 512; diff --git a/runtime-light/tl/tl-core.h b/runtime-light/tl/tl-core.h index 9c9d378d28..ccaf95e986 100644 --- a/runtime-light/tl/tl-core.h +++ b/runtime-light/tl/tl-core.h @@ -16,7 +16,7 @@ #include "runtime-common/core/allocator/script-allocator.h" #include "runtime-common/core/std/containers.h" #include "runtime-light/stdlib/diagnostics/logs.h" -#include "runtime-light/utils/concepts.h" +#include "runtime-light/type-traits/concepts.h" namespace tl { @@ -66,7 +66,7 @@ class storer { m_buffer.append_range(bytes); } - template + template requires std::convertible_to void store_trivial(const U& t) noexcept { store_bytes({reinterpret_cast(std::addressof(t)), sizeof(T)}); @@ -136,7 +136,7 @@ class fetcher { return bytes; } - template + template std::optional fetch_trivial() noexcept { if (m_remaining < sizeof(T)) { return std::nullopt; diff --git a/runtime-light/utils/concepts.h b/runtime-light/type-traits/concepts.h similarity index 88% rename from runtime-light/utils/concepts.h rename to runtime-light/type-traits/concepts.h index a2db5a90fe..56f125e20d 100644 --- a/runtime-light/utils/concepts.h +++ b/runtime-light/type-traits/concepts.h @@ -8,6 +8,8 @@ #include #include +namespace kphp::type_traits { + template concept standard_layout = std::is_standard_layout_v; @@ -18,3 +20,5 @@ concept hashable = requires(T t) { template concept in_types = (std::same_as || ...); + +} // namespace kphp::type_traits diff --git a/runtime-light/type-traits/functions.h b/runtime-light/type-traits/functions.h new file mode 100644 index 0000000000..0f92bd7de1 --- /dev/null +++ b/runtime-light/type-traits/functions.h @@ -0,0 +1,25 @@ +// Compiler for PHP (aka KPHP) +// Copyright (c) 2025 LLC «V Kontakte» +// Distributed under the GPL v3 License, see LICENSE.notice.txt + +#pragma once + +#include +#include + +namespace kphp::type_traits { + +template +constexpr size_t variant_index() noexcept { + static_assert(index < std::variant_size_v, "Type not found in variant"); + if constexpr (index == std::variant_size_v) { + // To prevent the error of substituting an index that is too large in variant_alternative_t + return index; + } else if constexpr (std::is_same_v, T>) { + return index; + } else { + return variant_index(); + } +} + +} // namespace kphp::type_traits diff --git a/runtime-light/utils/utils.cmake b/runtime-light/utils/utils.cmake deleted file mode 100644 index 911086ea12..0000000000 --- a/runtime-light/utils/utils.cmake +++ /dev/null @@ -1 +0,0 @@ -prepend(RUNTIME_LIGHT_UTILS_SRC utils/ php-assert.cpp) From 10f5b05d5504f713e16fead8ae983689a201e6c3 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Fri, 31 Oct 2025 16:31:19 +0300 Subject: [PATCH 2/5] small fix --- runtime-light/coroutine/detail/when-any.h | 2 +- runtime-light/coroutine/io-scheduler.h | 24 +++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/runtime-light/coroutine/detail/when-any.h b/runtime-light/coroutine/detail/when-any.h index 2c3bc7c7b4..a73796a210 100644 --- a/runtime-light/coroutine/detail/when-any.h +++ b/runtime-light/coroutine/detail/when-any.h @@ -123,7 +123,7 @@ class when_any_ready_awaitable> { if (auto task_result{std::forward(task).result()}; !result.has_value() && task_result.has_value()) { using result_variant_type = std::remove_cvref::type::value_type; using task_result_type = decltype(task_result)::value_type; - result = result_variant_type(std::in_place_index()>, *std::move(task_result)); + result = result_variant_type{std::in_place_index()>, *std::move(task_result)}; } }}; std::apply([&task_result_processor](auto&&... tasks) noexcept { (std::invoke(task_result_processor, std::forward(tasks)), ...); }, diff --git a/runtime-light/coroutine/io-scheduler.h b/runtime-light/coroutine/io-scheduler.h index 8adf8a7e09..b096deeea5 100644 --- a/runtime-light/coroutine/io-scheduler.h +++ b/runtime-light/coroutine/io-scheduler.h @@ -64,11 +64,11 @@ class io_scheduler { auto process_accept(k2::descriptor descriptor) noexcept -> void; auto update_timer() noexcept -> void; - [[nodiscard]] auto add_timer_token(k2::TimePoint time_point, kphp::coro::detail::poll_info& poll_info) noexcept - -> kphp::coro::detail::poll_info::timed_events::iterator; + [[nodiscard]] auto add_timer_token(k2::TimePoint time_point, + kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator; template - [[nodiscard]] auto add_timer_token(std::chrono::duration timeout, kphp::coro::detail::poll_info& poll_info) noexcept - -> kphp::coro::detail::poll_info::timed_events::iterator; + [[nodiscard]] auto add_timer_token(std::chrono::duration timeout, + kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator; auto remove_timer_token(kphp::coro::detail::poll_info::timed_events::iterator pos) noexcept -> void; public: @@ -162,8 +162,8 @@ class io_scheduler { * @param timeout Maximum duration to wait for the event (0 means no timeout). * @return A task that yields the poll status when completed. */ - [[nodiscard]] auto poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, std::chrono::nanoseconds timeout = std::chrono::nanoseconds{0}) noexcept - -> kphp::coro::task; + [[nodiscard]] auto poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, + std::chrono::nanoseconds timeout = std::chrono::nanoseconds{0}) noexcept -> kphp::coro::task; /** * @brief Accepts an incoming connection with optional timeout. @@ -330,8 +330,8 @@ inline auto io_scheduler::update_timer() noexcept -> void { } } -inline auto io_scheduler::add_timer_token(k2::TimePoint time_point, kphp::coro::detail::poll_info& poll_info) noexcept - -> kphp::coro::detail::poll_info::timed_events::iterator { +inline auto io_scheduler::add_timer_token(k2::TimePoint time_point, + kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator { const auto pos{m_timed_events.emplace(time_point, poll_info)}; if (pos == m_timed_events.begin()) { update_timer(); @@ -340,8 +340,8 @@ inline auto io_scheduler::add_timer_token(k2::TimePoint time_point, kphp::coro:: } template -auto io_scheduler::add_timer_token(std::chrono::duration timeout, kphp::coro::detail::poll_info& poll_info) noexcept - -> kphp::coro::detail::poll_info::timed_events::iterator { +auto io_scheduler::add_timer_token(std::chrono::duration timeout, + kphp::coro::detail::poll_info& poll_info) noexcept -> kphp::coro::detail::poll_info::timed_events::iterator { k2::TimePoint time_point{}; k2::instant(std::addressof(time_point)); time_point.time_point_ns += std::chrono::duration_cast(timeout).count(); @@ -505,8 +505,8 @@ auto io_scheduler::yield_for(std::chrono::duration amount co_await schedule_after(amount); } -inline auto io_scheduler::poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, std::chrono::nanoseconds timeout) noexcept - -> kphp::coro::task { +inline auto io_scheduler::poll(k2::descriptor descriptor, kphp::coro::poll_op poll_op, + std::chrono::nanoseconds timeout) noexcept -> kphp::coro::task { k2::StreamStatus stream_status{}; k2::stream_status(descriptor, std::addressof(stream_status)); if (stream_status.libc_errno != k2::errno_ok) [[unlikely]] { From 3955ff726094ac41e0cc23deebdb7f7d4a8832a1 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Fri, 31 Oct 2025 17:22:36 +0300 Subject: [PATCH 3/5] small fix --- runtime-light/coroutine/detail/when-any.h | 4 ++-- runtime-light/coroutine/io-scheduler.h | 1 + runtime-light/{type-traits => metaprogramming}/concepts.h | 4 ++-- .../functions.h => metaprogramming/type-functions.h} | 6 +++--- runtime-light/stdlib/string/regex-state.h | 4 ++-- runtime-light/tl/tl-core.h | 6 +++--- 6 files changed, 13 insertions(+), 12 deletions(-) rename runtime-light/{type-traits => metaprogramming}/concepts.h (89%) rename runtime-light/{type-traits/functions.h => metaprogramming/type-functions.h} (86%) diff --git a/runtime-light/coroutine/detail/when-any.h b/runtime-light/coroutine/detail/when-any.h index a73796a210..1ba1f892ed 100644 --- a/runtime-light/coroutine/detail/when-any.h +++ b/runtime-light/coroutine/detail/when-any.h @@ -15,8 +15,8 @@ #include "runtime-light/coroutine/concepts.h" #include "runtime-light/coroutine/type-traits.h" #include "runtime-light/coroutine/void-value.h" +#include "runtime-light/metaprogramming/type-functions.h" #include "runtime-light/stdlib/diagnostics/logs.h" -#include "runtime-light/type-traits/functions.h" namespace kphp::coro::detail::when_any { @@ -123,7 +123,7 @@ class when_any_ready_awaitable> { if (auto task_result{std::forward(task).result()}; !result.has_value() && task_result.has_value()) { using result_variant_type = std::remove_cvref::type::value_type; using task_result_type = decltype(task_result)::value_type; - result = result_variant_type{std::in_place_index()>, *std::move(task_result)}; + result = result_variant_type{std::in_place_index()>, *std::move(task_result)}; } }}; std::apply([&task_result_processor](auto&&... tasks) noexcept { (std::invoke(task_result_processor, std::forward(tasks)), ...); }, diff --git a/runtime-light/coroutine/io-scheduler.h b/runtime-light/coroutine/io-scheduler.h index b096deeea5..657dae1539 100644 --- a/runtime-light/coroutine/io-scheduler.h +++ b/runtime-light/coroutine/io-scheduler.h @@ -471,6 +471,7 @@ auto io_scheduler::schedule(coroutine_type coroutine, std::chrono::duration{co_await schedule(std::move(coroutine))}; } } + auto result{co_await kphp::coro::when_any(std::move(coroutine), make_timeout_task(timeout))}; if (std::holds_alternative(result)) [[unlikely]] { co_return std::unexpected{std::move(std::get<1>(result))}; diff --git a/runtime-light/type-traits/concepts.h b/runtime-light/metaprogramming/concepts.h similarity index 89% rename from runtime-light/type-traits/concepts.h rename to runtime-light/metaprogramming/concepts.h index 56f125e20d..0912acd607 100644 --- a/runtime-light/type-traits/concepts.h +++ b/runtime-light/metaprogramming/concepts.h @@ -8,7 +8,7 @@ #include #include -namespace kphp::type_traits { +namespace kphp::concepts { template concept standard_layout = std::is_standard_layout_v; @@ -21,4 +21,4 @@ concept hashable = requires(T t) { template concept in_types = (std::same_as || ...); -} // namespace kphp::type_traits +} // namespace kphp::concepts diff --git a/runtime-light/type-traits/functions.h b/runtime-light/metaprogramming/type-functions.h similarity index 86% rename from runtime-light/type-traits/functions.h rename to runtime-light/metaprogramming/type-functions.h index 0f92bd7de1..620ddf1969 100644 --- a/runtime-light/type-traits/functions.h +++ b/runtime-light/metaprogramming/type-functions.h @@ -7,10 +7,10 @@ #include #include -namespace kphp::type_traits { +namespace kphp::type_functions { template -constexpr size_t variant_index() noexcept { +consteval size_t variant_index() noexcept { static_assert(index < std::variant_size_v, "Type not found in variant"); if constexpr (index == std::variant_size_v) { // To prevent the error of substituting an index that is too large in variant_alternative_t @@ -22,4 +22,4 @@ constexpr size_t variant_index() noexcept { } } -} // namespace kphp::type_traits +} // namespace kphp::type_functions diff --git a/runtime-light/stdlib/string/regex-state.h b/runtime-light/stdlib/string/regex-state.h index 50b43312c8..6d6fb64b1e 100644 --- a/runtime-light/stdlib/string/regex-state.h +++ b/runtime-light/stdlib/string/regex-state.h @@ -10,11 +10,11 @@ #include "common/mixin/not_copyable.h" #include "runtime-common/core/allocator/script-allocator.h" #include "runtime-common/core/std/containers.h" +#include "runtime-light/metaprogramming/concepts.h" #include "runtime-light/stdlib/string/regex-include.h" -#include "runtime-light/type-traits/concepts.h" struct RegexInstanceState final : private vk::not_copyable { - template + template using unordered_map = kphp::stl::unordered_map; static constexpr size_t MAX_SUBPATTERNS_COUNT = 512; diff --git a/runtime-light/tl/tl-core.h b/runtime-light/tl/tl-core.h index ccaf95e986..6be470c403 100644 --- a/runtime-light/tl/tl-core.h +++ b/runtime-light/tl/tl-core.h @@ -15,8 +15,8 @@ #include "common/algorithms/find.h" #include "runtime-common/core/allocator/script-allocator.h" #include "runtime-common/core/std/containers.h" +#include "runtime-light/metaprogramming/concepts.h" #include "runtime-light/stdlib/diagnostics/logs.h" -#include "runtime-light/type-traits/concepts.h" namespace tl { @@ -66,7 +66,7 @@ class storer { m_buffer.append_range(bytes); } - template + template requires std::convertible_to void store_trivial(const U& t) noexcept { store_bytes({reinterpret_cast(std::addressof(t)), sizeof(T)}); @@ -136,7 +136,7 @@ class fetcher { return bytes; } - template + template std::optional fetch_trivial() noexcept { if (m_remaining < sizeof(T)) { return std::nullopt; From 610c2040e6b505b9d6a582d0910bd8b43535377b Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Fri, 31 Oct 2025 17:25:09 +0300 Subject: [PATCH 4/5] small fix --- runtime-light/coroutine/detail/when-any.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime-light/coroutine/detail/when-any.h b/runtime-light/coroutine/detail/when-any.h index 1ba1f892ed..f124f5928e 100644 --- a/runtime-light/coroutine/detail/when-any.h +++ b/runtime-light/coroutine/detail/when-any.h @@ -123,7 +123,8 @@ class when_any_ready_awaitable> { if (auto task_result{std::forward(task).result()}; !result.has_value() && task_result.has_value()) { using result_variant_type = std::remove_cvref::type::value_type; using task_result_type = decltype(task_result)::value_type; - result = result_variant_type{std::in_place_index()>, *std::move(task_result)}; + result = + result_variant_type{std::in_place_index()>, *std::move(task_result)}; } }}; std::apply([&task_result_processor](auto&&... tasks) noexcept { (std::invoke(task_result_processor, std::forward(tasks)), ...); }, From 168c2fdbed0e3f705dd9eb6b6d86f5c53b28b165 Mon Sep 17 00:00:00 2001 From: Vadim Sadokhov Date: Wed, 5 Nov 2025 17:31:12 +0300 Subject: [PATCH 5/5] small fix --- runtime-light/metaprogramming/type-functions.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/runtime-light/metaprogramming/type-functions.h b/runtime-light/metaprogramming/type-functions.h index 620ddf1969..350fa453d7 100644 --- a/runtime-light/metaprogramming/type-functions.h +++ b/runtime-light/metaprogramming/type-functions.h @@ -5,17 +5,15 @@ #pragma once #include +#include #include namespace kphp::type_functions { template +requires(index < std::variant_size_v) consteval size_t variant_index() noexcept { - static_assert(index < std::variant_size_v, "Type not found in variant"); - if constexpr (index == std::variant_size_v) { - // To prevent the error of substituting an index that is too large in variant_alternative_t - return index; - } else if constexpr (std::is_same_v, T>) { + if constexpr (std::is_same_v, T>) { return index; } else { return variant_index();