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

[FIX] don't hard-fail on concept check #1394

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

h-2
Copy link
Member

@h-2 h-2 commented Dec 2, 2019

You may not do the things you are doing in the signature of the requires expression, because their validity depends on the result of the requires expression.

This leads to hard-failure for types that would normally soft-fail. Since the concept is checked on globally defined operator| this can lead to all sorts of view-resolution failures to land here and hard-fail.

@sarahet Please check if this removes the first error.

@h-2 h-2 requested a review from smehringer December 2, 2019 16:59
@codecov
Copy link

codecov bot commented Dec 2, 2019

Codecov Report

Merging #1394 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1394   +/-   ##
=======================================
  Coverage   97.53%   97.53%           
=======================================
  Files         228      228           
  Lines        8731     8731           
=======================================
  Hits         8516     8516           
  Misses        215      215
Impacted Files Coverage Δ
include/seqan3/argument_parser/argument_parser.hpp 98.54% <ø> (ø) ⬆️
include/seqan3/argument_parser/validators.hpp 88.69% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e694d20...cde9729. Read the comment docs.

{
typename std::remove_reference_t<validator_type>::value_type;

{ validator(value) } -> void;
{ validator(typename std::remove_reference_t<validator_type>::value_type{}) } -> void;
Copy link
Member

Choose a reason for hiding this comment

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

I would use decval in case the value type is not default constructible?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but it doesn't wark because GCC7 and GCC8 at least trigger ODR-use of that statement (although they shouldn't) which results in the compiler telling you that you cannot use declval in an evaluated context. 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I've seen this as well, which is annoying.

@h-2
Copy link
Member Author

h-2 commented Dec 3, 2019

(do not merge yet, still WIP)

@h-2 h-2 force-pushed the fix/arg_parser_concept_check branch from 17a41ae to e8f1eca Compare December 3, 2019 21:35
@h-2
Copy link
Member Author

h-2 commented Dec 3, 2019

Ok, a different "fix" was necessary, because the problem is that the concept check of GCC doesn't cope with something existing, but being private/protected. It will result in hard errors instead of failing the concept.

But since ::value_type is taken as an indicator for iterators and ranges it's not the best choice anyway. I have just renamed it here which solves all the problems. Is that ok with you, @smehringer ?

@h-2 h-2 requested a review from smehringer December 3, 2019 21:39
@@ -293,7 +293,7 @@ class argument_parser
template <typename option_type, validator validator_type = detail::default_validator<option_type>>
//!\cond
requires (argument_parser_compatible_option<option_type> ||
argument_parser_compatible_option<typename option_type::value_type>) &&
argument_parser_compatible_option<std::ranges::range_value_t<option_type>>) &&
Copy link
Member Author

Choose a reason for hiding this comment

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

this is just a drive-by fix

@smehringer
Copy link
Member

fine with me. Good thing we are not stable yet...

@smehringer
Copy link
Member

CI is failing though

@@ -48,6 +48,8 @@ If possible, provide tooling that performs the changes, e.g. a shell-script.
* **Changed class signature of input/output file validators:**
Most user code will be unaffected; to fix possible compiler errors you need to add an empty template parameter list to
the respective instances (e.g. change `input_file_validator` to `input_file_validator<>`).
* The member type that denotes which arguments a `validator` can validate has been renamed from `value_type` to
Copy link
Contributor

Choose a reason for hiding this comment

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

a) why and b) what has this to do with the hard fails on concept checks?

Copy link
Member Author

Choose a reason for hiding this comment

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

See above

Ok, a different "fix" was necessary, because the problem is that the concept check of GCC doesn't cope with something existing, but being private/protected. It will result in hard errors instead of failing the concept.

Copy link
Member Author

Choose a reason for hiding this comment

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

(our ranges often have protected or private ::value_type)

@marehr
Copy link
Member

marehr commented Dec 5, 2019

@h-2
Copy link
Member Author

h-2 commented Dec 5, 2019

https://travis-ci.org/seqan/seqan3/jobs/620336210#L5884-L5962

I know, I hope to have time for it tomorrow.

@h-2 h-2 force-pushed the fix/arg_parser_concept_check branch from e8f1eca to 32f0e0c Compare December 5, 2019 19:44
@h-2 h-2 requested a review from rrahn December 5, 2019 19:44
Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

I would suggest a different name. I also spotted some documentation issues, that could be fixed right along. Many thanks

@@ -97,7 +97,7 @@ SEQAN3_CONCEPT validator = std::copyable<remove_cvref_t<validator_type>> &&
* \ingroup argument_parser
* \implements seqan3::validator
*
* \tparam option_value_type Must be a (container of) arithmetic type(s).
* \tparam option_input_type Must be a (container of) arithmetic type(s).
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, but this class has no template parameter

@@ -176,12 +176,12 @@ class arithmetic_range_validator
*
* \include test/snippet/argument_parser/validators_2.cpp
*/
template <typename option_value_type>
template <typename option_input_type>
Copy link
Contributor

Choose a reason for hiding this comment

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

here tparam is not documented 🤕

CHANGELOG.md Outdated
@@ -48,6 +48,8 @@ If possible, provide tooling that performs the changes, e.g. a shell-script.
* **Changed class signature of input/output file validators:**
Most user code will be unaffected; to fix possible compiler errors you need to add an empty template parameter list to
the respective instances (e.g. change `input_file_validator` to `input_file_validator<>`).
* The member type that denotes which arguments a `validator` can validate has been renamed from `value_type` to
`input_type`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess calling it option_value_type would be more fitting. At the end a validator validates the value of an option. Accordingly, we want to know the value type an option represents.

@@ -896,14 +896,14 @@ namespace detail
* The default validator is needed to make the validator parameter of
* argument_parser::add_option and argument_parser::add_option optional.
*/
template <typename option_value_type>
template <typename option_input_type>
Copy link
Contributor

Choose a reason for hiding this comment

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

tparam not documented

Copy link
Contributor

Choose a reason for hiding this comment

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

it would be then as well option_value_t

@@ -176,12 +176,12 @@ class arithmetic_range_validator
*
* \include test/snippet/argument_parser/validators_2.cpp
*/
template <typename option_value_type>
template <typename option_input_type>
Copy link
Contributor

Choose a reason for hiding this comment

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

This would then be option_value_t to not clash with the typedef inside.

@h-2 h-2 force-pushed the fix/arg_parser_concept_check branch from 32f0e0c to 9572910 Compare December 8, 2019 00:25
@h-2 h-2 requested a review from rrahn December 8, 2019 00:25
Copy link
Contributor

@rrahn rrahn left a comment

Choose a reason for hiding this comment

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

lgtm

@h-2 h-2 force-pushed the fix/arg_parser_concept_check branch from 9572910 to cde9729 Compare December 9, 2019 12:57
@h-2 h-2 merged commit fdbd8ba into seqan:master Dec 9, 2019
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.

None yet

4 participants