Scope::clone_visible clones value access mode also.

This commit is contained in:
Stephen Chung 2022-01-26 22:15:19 +08:00
parent 14e42f436f
commit 538af8caee
2 changed files with 10 additions and 1 deletions

View File

@ -4,6 +4,11 @@ Rhai Release Notes
Version 1.5.0 Version 1.5.0
============= =============
Bug fixes
---------
* In `Scope::clone_visible`, constants are now properly cloned as constants.
New features New features
------------ ------------

View File

@ -534,8 +534,12 @@ impl Scope<'_> {
Self::new(), Self::new(),
|mut entries, (index, (name, alias))| { |mut entries, (index, (name, alias))| {
if !entries.names.iter().any(|(key, _)| key == name) { if !entries.names.iter().any(|(key, _)| key == name) {
let orig_value = &self.values[len - 1 - index];
let mut value = orig_value.clone();
value.set_access_mode(orig_value.access_mode());
entries.names.push((name.clone(), alias.clone())); entries.names.push((name.clone(), alias.clone()));
entries.values.push(self.values[len - 1 - index].clone()); entries.values.push(value);
} }
entries entries
}, },