From b5a2937336a43f913c04ccef31ff58a799bcca49 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sat, 24 Apr 2021 13:42:30 +0800 Subject: [PATCH] Do not treat Expr::Index with pure index as pure. --- CHANGELOG.md | 1 + src/ast.rs | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65c55117..235048e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Bug fixes --------- * Fixed bug when position is zero in `insert` and `split_at` methods for arrays. +* Indexing operations with pure index values are no longer considered pure due to the possibility of indexers. Breaking changes ---------------- diff --git a/src/ast.rs b/src/ast.rs index 023302a2..3d16bf68 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -1899,9 +1899,7 @@ impl Expr { Self::Map(x, _) => x.0.iter().map(|(_, v)| v).all(Self::is_pure), - Self::Index(x, _) | Self::And(x, _) | Self::Or(x, _) => { - x.lhs.is_pure() && x.rhs.is_pure() - } + Self::And(x, _) | Self::Or(x, _) => x.lhs.is_pure() && x.rhs.is_pure(), Self::Stmt(x) => x.0.iter().all(Stmt::is_pure),