From dd664e3cdb60706a8961368861048ae63f4d7c35 Mon Sep 17 00:00:00 2001 From: rose <132@ikl.sh> Date: Tue, 19 Aug 2025 16:28:30 -0400 Subject: [PATCH] Add assertion that DeprecationEntry flag do not have dashes (#16475) Added a `debug_assert` when using `DeprecationType::Flag` to ensure that the dashes aren't included as part of the flag name. This will hopefully catch something like the issue discovered in #16473 from occurring. ## Release notes summary - What our users need to know N/A --------- Co-authored-by: Stefan Holderbach --- crates/nu-protocol/src/deprecation.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/deprecation.rs b/crates/nu-protocol/src/deprecation.rs index d7ab11f52a..dd8d2bc693 100644 --- a/crates/nu-protocol/src/deprecation.rs +++ b/crates/nu-protocol/src/deprecation.rs @@ -87,7 +87,16 @@ impl DeprecationEntry { fn check(&self, call: &Call) -> bool { match &self.ty { DeprecationType::Command => true, - DeprecationType::Flag(flag) => call.get_named_arg(flag).is_some(), + DeprecationType::Flag(flag) => { + // Make sure we don't accidentally have dashes in the flag + debug_assert!( + !flag.starts_with('-'), + "DeprecationEntry for {} should not include dashes in the flag name!", + flag + ); + + call.get_named_arg(flag).is_some() + } } }