Skip to content

Conversation

@wanderview
Copy link
Contributor

Currently the opts_present() function only checks to see if the option is
configured in the match, but doesn't actually check to see if the option
value has been set. This means that opt_present('h') may return false while
opts_present([~'h']) returns true.

Add a test case to catch this condition and fix opts_present() to check
the value before returning true.

Note, there is another API difference between these two functions that this
does not address. Currently if you pass a non-configured option to
opt_present() the program will fail!(), but opts_present() simply returns
false. If it is acceptable to standardize on the fail!() then opts_present()
should probably be implemented in terms of the opt_present() function.

Currently the opts_present() function only checks to see if the option is
configured in the match, but doesn't actually check to see if the option
value has been set.  This means that opt_present('h') may return false while
opts_present([~'h']) returns true.

Add a test case to catch this condition and fix opts_present() to check
the value before returning true.

Note, there is another API difference between these two functions that this
does not address.  Currently if you pass a non-configured option to
opt_present() the program will fail!(), but opts_present() simply returns
false.  If it is acceptable to standardize on the fail!() then opts_present()
should probably be implemented in terms of the opt_present() function.
@wanderview
Copy link
Contributor Author

Sounds good. I can pursue using conditions in a separate pull request. Would you like all fail! uses in std::getopts converted over?

Thanks.

bors added a commit that referenced this pull request Mar 12, 2013
…ydon

Currently the opts_present() function only checks to see if the option is
configured in the match, but doesn't actually check to see if the option
value has been set.  This means that opt_present('h') may return false while
opts_present([~'h']) returns true.

Add a test case to catch this condition and fix opts_present() to check
the value before returning true.

Note, there is another API difference between these two functions that this
does not address.  Currently if you pass a non-configured option to
opt_present() the program will fail!(), but opts_present() simply returns
false.  If it is acceptable to standardize on the fail!() then opts_present()
should probably be implemented in terms of the opt_present() function.
@bors bors closed this Mar 12, 2013
@bors bors merged commit 4f4f69d into rust-lang:incoming Mar 12, 2013
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2020
…flip1995

integer_arithmetic: detect integer arithmetic on references.

changelog: integer_arithmetic fix false negatives with references on integers

Fixes rust-lang#5328
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.

3 participants