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

change assert by FC_ASSERT #1762

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

oxarbitrage
Copy link
Member

#1755

In the last core team meeting @nathanhourt explained he is not sure on the use of extension option to do named arguments. He will do more research as he haves other options.

Still, i think this can still be changed and it is what this pull do.

@abitmore abitmore added this to the 3.2.0 - Feature Release milestone May 15, 2019
@@ -150,7 +150,7 @@ struct graphene_extension_from_variant_visitor
if( it != vo.end() )
{
from_variant( it->value(), (value.*member), _max_depth );
assert( count_left > 0 ); // x.find(k) returns true for n distinct values of k only if x.size() >= n
FC_ASSERT( count_left > 0 ); // x.find(k) returns true for n distinct values of k only if x.size() >= n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a meaningful error message.
Actually I can't think of a situation where this assertion would trigger.
The visitor is called once per extension member, with distinct names. Only names that are found are counted, so the only way to have count_left == 0 is to call it more than once with a given name.

The only case I can think of where this could happen is if the extension type is a derived class, and both the parent and the extension have a member with the same name. Or if a member name appears more than once in the corresponding FC_REFLECT macro. Both would be a bug in core, not a problem with the incoming variant.

@pmconrad
Copy link
Contributor

I think what will be more important for API users is error messages in the FC_ASSERTs in lines 173 and 179. The one in 179 in particular should mention the names that were not used.

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.

4 participants