diff --git a/clap_builder/src/parser/parser.rs b/clap_builder/src/parser/parser.rs index d820c63995b..81e47a004b5 100644 --- a/clap_builder/src/parser/parser.rs +++ b/clap_builder/src/parser/parser.rs @@ -54,7 +54,15 @@ impl<'cmd> Parser<'cmd> { ) -> ClapResult<()> { debug!("Parser::get_matches_with"); - ok!(self.parse(matcher, raw_args, args_cursor)); + ok!(self + .parse(matcher, raw_args, args_cursor) + .inspect_err(|_err| { + if self.cmd.is_ignore_errors_set() { + #[cfg(feature = "env")] + let _ = self.add_env(matcher); + let _ = self.add_defaults(matcher); + } + })); ok!(self.resolve_pending(matcher)); #[cfg(feature = "env")] diff --git a/tests/builder/ignore_errors.rs b/tests/builder/ignore_errors.rs index 850699a21b0..702b7746e63 100644 --- a/tests/builder/ignore_errors.rs +++ b/tests/builder/ignore_errors.rs @@ -113,7 +113,7 @@ fn unexpected_argument() { m.get_one::("config").cloned(), Some("config file".to_owned()) ); - assert_eq!(m.get_one::("unset-flag").copied(), None); + assert_eq!(m.get_one::("unset-flag").copied(), Some(false)); } #[test]