diff --git a/crates/nu-command/tests/commands/mut_.rs b/crates/nu-command/tests/commands/mut_.rs index e66348f8f2..52aa9fcff1 100644 --- a/crates/nu-command/tests/commands/mut_.rs +++ b/crates/nu-command/tests/commands/mut_.rs @@ -141,3 +141,10 @@ fn mut_raw_string() { let actual = nu!(r#"mut x = r#'abc'#; $x"#); assert_eq!(actual.out, "abc"); } + +#[test] +fn def_should_not_mutate_mut() { + let actual = nu!("mut a = 3; def foo [] { $a = 4}"); + assert!(actual.err.contains("capture of mutable variable")); + assert!(!actual.status.success()) +}