From 78b5c9fd4ee99a2a3c74aaa62e3a2c5680b4b711 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Fri, 18 Feb 2022 19:13:09 +0800 Subject: [PATCH] Fix bug in Scope::is_constant. --- CHANGELOG.md | 1 + src/types/scope.rs | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab32c6e4..513329e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. +* `Scope::is_constant` now returns the correct value. Enhancements ------------ diff --git a/src/types/scope.rs b/src/types/scope.rs index 7114f8a3..310877c7 100644 --- a/src/types/scope.rs +++ b/src/types/scope.rs @@ -375,9 +375,11 @@ impl Scope<'_> { /// ``` #[inline] pub fn is_constant(&self, name: &str) -> Option { - self.get_index(name).and_then(|(.., access)| match access { - AccessMode::ReadWrite => None, - AccessMode::ReadOnly => Some(true), + self.get_index(name).and_then(|(.., access)| { + Some(match access { + AccessMode::ReadWrite => false, + AccessMode::ReadOnly => true, + }) }) } /// Update the value of the named entry in the [`Scope`] if it already exists and is not constant.