mirror of
https://github.com/nushell/nushell
synced 2024-12-26 04:53:09 +00:00
Tests: add a test to make sure that function can't use mutable variable (#14314)
@sholderbach suggested that we need to have a test for a function can't use mutable variable. https://github.com/nushell/nushell/pull/14311#issuecomment-2470035194 So this pr is going to add a case for it. --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
e6f55da080
commit
a3c145432e
1 changed files with 7 additions and 0 deletions
|
@ -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())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue