mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 02:24:58 +02:00
Start improving mutable capture error
This commit is contained in:
@ -6522,7 +6522,12 @@ pub fn discover_captures_in_expr(
|
||||
if !seen.contains(var_id) {
|
||||
if let Some(variable) = working_set.get_variable_if_possible(*var_id) {
|
||||
if variable.mutable {
|
||||
return Err(ParseError::CaptureOfMutableVar(*span));
|
||||
let var_name = working_set.get_span_contents(*span);
|
||||
return Err(ParseError::CaptureOfMutableVar {
|
||||
var: String::from_utf8_lossy(var_name).into_owned(),
|
||||
var_span: span.before(),
|
||||
closure_span: block.span,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user