diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-04-19 17:51:33 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-04-19 17:51:33 +0200 |
| commit | f08ae95b9d8be5165f9c8cac4c755d0510c3a18a (patch) | |
| tree | cc4bdf617618535d128e1a5611f270c8a99df31f /src/eval/scope.rs | |
| parent | 5a6330dbfce9ed30c77502b66db843fd72b2d267 (diff) | |
Fix argument sinks
Fixes #886.
Diffstat (limited to 'src/eval/scope.rs')
| -rw-r--r-- | src/eval/scope.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/eval/scope.rs b/src/eval/scope.rs index f2207188..76633bf2 100644 --- a/src/eval/scope.rs +++ b/src/eval/scope.rs @@ -38,20 +38,20 @@ impl<'a> Scopes<'a> { /// Try to access a variable immutably. pub fn get(&self, var: &str) -> StrResult<&Value> { - Ok(std::iter::once(&self.top) + std::iter::once(&self.top) .chain(self.scopes.iter().rev()) .chain(self.base.map(|base| base.global.scope())) .find_map(|scope| scope.get(var)) - .ok_or(eco_format!("unknown variable: {}", var))?) + .ok_or_else(|| eco_format!("unknown variable: {}", var)) } /// Try to access a variable immutably in math. pub fn get_in_math(&self, var: &str) -> StrResult<&Value> { - Ok(std::iter::once(&self.top) + std::iter::once(&self.top) .chain(self.scopes.iter().rev()) .chain(self.base.map(|base| base.math.scope())) .find_map(|scope| scope.get(var)) - .ok_or(eco_format!("unknown variable: {}", var))?) + .ok_or_else(|| eco_format!("unknown variable: {}", var)) } /// Try to access a variable mutably. |
