From 18b48e1349033b7c592ab93f4bf1fef909c84cde Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Sun, 17 Nov 2024 20:16:18 +0800 Subject: [PATCH] merge from main --- crates/nu-command/tests/commands/mut_.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/nu-command/tests/commands/mut_.rs b/crates/nu-command/tests/commands/mut_.rs index 52aa9fcff1..107fa62cce 100644 --- a/crates/nu-command/tests/commands/mut_.rs +++ b/crates/nu-command/tests/commands/mut_.rs @@ -148,3 +148,14 @@ fn def_should_not_mutate_mut() { assert!(actual.err.contains("capture of mutable variable")); assert!(!actual.status.success()) } + +#[test] +fn mut_with_bad_syntax_raises_parse_error() { + let actual = nu!("let x = 3; $x = 4"); + assert!(actual + .err + .contains("parser::assignment_requires_mutable_variable")); + + let actual = nu!("mut x = 3; x = 5"); + assert!(actual.err.contains("parser::assignment_requires_variable")); +}