Fix bug with capturing undefined variable.
This commit is contained in:
@@ -1016,7 +1016,7 @@ impl Engine {
|
||||
|
||||
// Share statement
|
||||
#[cfg(not(feature = "no_closure"))]
|
||||
Stmt::Share(name, ..) => {
|
||||
Stmt::Share(name, pos) => {
|
||||
if let Some((index, ..)) = scope.get_index(name) {
|
||||
let val = scope.get_mut_by_index(index);
|
||||
|
||||
@@ -1024,10 +1024,10 @@ impl Engine {
|
||||
// Replace the variable with a shared value.
|
||||
*val = std::mem::take(val).into_shared();
|
||||
}
|
||||
Ok(Dynamic::UNIT)
|
||||
} else {
|
||||
unreachable!("variable {} not found for sharing", name);
|
||||
Err(ERR::ErrorVariableNotFound(name.to_string(), *pos).into())
|
||||
}
|
||||
Ok(Dynamic::UNIT)
|
||||
}
|
||||
|
||||
_ => unreachable!("statement cannot be evaluated: {:?}", stmt),
|
||||
|
Reference in New Issue
Block a user