Skip to content

Conversation

@linh2931
Copy link
Contributor

@linh2931 linh2931 commented Jul 21, 2025

Change Description

Fix the problem of action wrappers and call wrappers compile failures if their first argument is bool, and add tests for it.

For example, a call wrapper like

[[eosio::call]]
bool bool_ret_bool_arg(bool b) { return b; };
using bool_ret_bool_arg_func = eosio::call_wrapper<"bool_ret_bool_arg"_i, &sync_call_callee::bool_ret_bool_arg>;

CDT will fail the compile with

.../build/bin/../include/eosiolib/contracts/eosio/detail.hpp:71:29: error: ambiguous partial specializations of 'is_same<bool, bool>'
      static_assert(detail::is_same<typename convert<T>::type, typename convert<typename std::tuple_element<I, deduced<Function>>::type>::type>::value);
                            ^
.../build/bin/../include/eosiolib/contracts/eosio/detail.hpp:79:17: note: in instantiation of template class 'eosio::detail::check_types<&sync_call_callee::void_ret_bool_arg, 0, bool>' requested here
         return check_types<Function, 0, Ts...>::value;
                ^
.../build/bin/../include/eosiolib/contracts/eosio/call.hpp:115:32: note: in instantiation of function template specialization 'eosio::detail::type_check<&sync_call_callee::void_ret_bool_arg, bool>' requested here
         static_assert(detail::type_check<Func_Ref, Args...>());
                               ^
.../tests/unit/test_contracts/sync_call_caller.cpp:195:61: note: in instantiation of function template specialization 'eosio::call_wrapper<15588028823843593861, &sync_call_callee::void_ret_bool_arg, eosio::access_mode::read_write, eosio::support_mode::abort_op>::operator()<bool>' requested here
      sync_call_callee::void_ret_bool_arg_func{ "callee"_n }(true);
                                                            ^
.../build/bin/../include/eosiolib/contracts/eosio/detail.hpp:44:11: note: partial specialization matches [with U = bool]
   struct is_same<bool,U> { static constexpr bool value = std::is_integral<U>::value; };
          ^
.../build/bin/../include/eosiolib/contracts/eosio/detail.hpp:47:11: note: partial specialization matches [with T = bool]
   struct is_same<T,bool> { static constexpr bool value = std::is_integral<T>::value; };

The problem is due to partial specialization for bool type.

Resolves #370

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@linh2931 linh2931 requested review from heifner and spoonincode July 21, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Action wrappers and call wrappers fail to compile if their first argument is bool

4 participants