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

opt_present with invalid value should not panic #51

Open
mqudsi opened this issue Aug 12, 2017 · 1 comment
Open

opt_present with invalid value should not panic #51

mqudsi opened this issue Aug 12, 2017 · 1 comment

Comments

@mqudsi
Copy link

mqudsi commented Aug 12, 2017

If matches.opt_present is called with a not-defined option, that should either be a compile-time error (somehow) or it should return false; currently it panics instead.

KodrAus added a commit that referenced this issue May 27, 2018
test case to check opt_present() panic for undefined options #51.
@KodrAus
Copy link
Contributor

KodrAus commented Oct 15, 2018

The current behaviour of panicking highlights an issue in the program itself where it's trying to find a value that'll never return true. I think this is maybe a little surprising but is a reasonable way to identify a possible bug.

We should note in the crate docs that the method will panic if it's given an option that doesn't exist.

t-rapp added a commit to t-rapp/getopts that referenced this issue Sep 6, 2019
…panic

Also update the name argument to make it more obvious what the "option
name" text part is referring to.

Relates to issue rust-lang#51.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants