diff --git a/CHANGELOG.md b/CHANGELOG.md index 112423ad..068a83de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ Rhai Release Notes Version 1.5.0 ============= +Bug fixes +--------- + +* In `Scope::clone_visible`, constants are now properly cloned as constants. + New features ------------ diff --git a/src/types/scope.rs b/src/types/scope.rs index 56f21748..e6b0de89 100644 --- a/src/types/scope.rs +++ b/src/types/scope.rs @@ -534,8 +534,12 @@ impl Scope<'_> { Self::new(), |mut entries, (index, (name, alias))| { 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.values.push(self.values[len - 1 - index].clone()); + entries.values.push(value); } entries },