diff --git a/crates/nu-command/tests/commands/match_.rs b/crates/nu-command/tests/commands/match_.rs index 41e0c79165..c03eed5f4f 100644 --- a/crates/nu-command/tests/commands/match_.rs +++ b/crates/nu-command/tests/commands/match_.rs @@ -132,6 +132,12 @@ fn match_constant_7() { assert_eq!(actual.out, "success"); } +#[test] +fn match_null() { + let actual = nu!(r#"match null { null => { print "success"}, _ => { print "failure" }}"#); + assert_eq!(actual.out, "success"); +} + #[test] fn match_or_pattern() { let actual = nu!( diff --git a/crates/nu-protocol/src/engine/pattern_match.rs b/crates/nu-protocol/src/engine/pattern_match.rs index 36419a0fcf..8626a89943 100644 --- a/crates/nu-protocol/src/engine/pattern_match.rs +++ b/crates/nu-protocol/src/engine/pattern_match.rs @@ -96,6 +96,9 @@ impl Matcher for Pattern { Pattern::Value(pattern_value) => { // TODO: Fill this out with the rest of them match &pattern_value.expr { + Expr::Nothing => { + matches!(value, Value::Nothing { .. }) + } Expr::Int(x) => { if let Value::Int { val, .. } = &value { x == val