Fix bug in Scope::is_constant.
This commit is contained in:
parent
ef87ae48c1
commit
78b5c9fd4e
@ -8,6 +8,7 @@ Bug fixes
|
|||||||
---------
|
---------
|
||||||
|
|
||||||
* Invalid property or method access such as `a.b::c.d` or `a.b::func()` no longer panics but properly returns a syntax error.
|
* Invalid property or method access such as `a.b::c.d` or `a.b::func()` no longer panics but properly returns a syntax error.
|
||||||
|
* `Scope::is_constant` now returns the correct value.
|
||||||
|
|
||||||
Enhancements
|
Enhancements
|
||||||
------------
|
------------
|
||||||
|
@ -375,9 +375,11 @@ impl Scope<'_> {
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_constant(&self, name: &str) -> Option<bool> {
|
pub fn is_constant(&self, name: &str) -> Option<bool> {
|
||||||
self.get_index(name).and_then(|(.., access)| match access {
|
self.get_index(name).and_then(|(.., access)| {
|
||||||
AccessMode::ReadWrite => None,
|
Some(match access {
|
||||||
AccessMode::ReadOnly => Some(true),
|
AccessMode::ReadWrite => false,
|
||||||
|
AccessMode::ReadOnly => true,
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/// Update the value of the named entry in the [`Scope`] if it already exists and is not constant.
|
/// Update the value of the named entry in the [`Scope`] if it already exists and is not constant.
|
||||||
|
Loading…
Reference in New Issue
Block a user