Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[1.0 -> main] Don't use deduced return type in test contract as it fails in template instantation #680

Merged
merged 4 commits into from
Sep 1, 2024

Conversation

greg7mdp
Copy link
Contributor

Partially resolves #677.

This resolves the first issue:

/home/greg/github/enf/cdt/build_clang18_debug/bin/../include/eosiolib/contracts/eosio/multi_index.hpp:442:96: error: function 'primary_key' with deduced return type cannot be used before it is defined

Remaining issue

An issue remains with the use of the macro EOSIO_DISPATCH( eosiosystem::system_contract, ... in unittests/contracts/eosio.system/eosio.system.cpp.

Original issue was:

error: case value is not a constant expression because check() is not constexpr.

I tried making check() constexpr in cdt's libraries/eosiolib/core/eosio/check.hpp, but check calls the extern "C" functions eosio_assert which I don't think can be made constexpr.

So I tried updating the EOSIO_DISPATCH to use a series of if () ... else instead of a switch statement. This appears to work, but the EOSIO_DISPATCH still fails on this contract, and it appears that it is because it attempts to dispatch too many actions:

EOSIO_DISPATCH( eosiosystem::system_contract,
// native.hpp (newaccount definition is actually in eosio.system.cpp)
(newaccount)(updateauth)(deleteauth)(linkauth)(unlinkauth)(canceldelay)(onerror)(setabi)
// eosio.system.cpp
      (init)(setram)(setramrate)(setparams)(setpriv)(setalimits)(rmvproducer)(updtrevision)(bidname)(bidrefund)
// rex.cpp
      (deposit)(withdraw)(buyrex)(unstaketorex)(sellrex)(cnclrexorder)(rentcpu)(rentnet)(fundcpuloan)(fundnetloan)
      (defcpuloan)(defnetloan)(updaterex)(consolidate)(rexexec)(closerex)
// delegate_bandwidth.cpp
      (buyrambytes)(buyram)(sellram)(delegatebw)(undelegatebw)(refund)
// voting.cpp
      (regproducer)(unregprod)(voteproducer)(regproxy)
// producer_pay.cpp
      (onblock)(claimrewards)
)

The same macro builds fine if I remove a bunch of the actions. I wonder if we hit a preprocessor recursion limit, but I don't see an option to change it.

@greg7mdp greg7mdp merged commit 53b2392 into main Sep 1, 2024
36 checks passed
@greg7mdp greg7mdp deleted the gh_677_main branch September 1, 2024 00:35
@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: TEST
summary: Use explicit type on test contract to work around deduced returned type error.
Note:end

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.

Fix compilation of test contracts in spring (using cdt 4.1.0-rc3)
4 participants