From d0ba8c376e8d158b073b494cfed6ccba492e0882 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sat, 18 Apr 2015 15:14:34 -0500
Subject: [PATCH] Fix no-subst/matching logic in ExpandingSubstitutionMapper

---
 loopy/symbolic.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/loopy/symbolic.py b/loopy/symbolic.py
index 9309fd041..09cce65cb 100644
--- a/loopy/symbolic.py
+++ b/loopy/symbolic.py
@@ -586,10 +586,10 @@ class ExpandingSubstitutionMapper(ExpandingIdentityMapper):
 
     def map_variable(self, expr, expn_state):
         result = self.subst_func(expr)
-        if result is not None or not self.within(expn_state.stack):
-            return result
-        else:
+        if result is None or not self.within(expn_state.stack):
             return ExpandingIdentityMapper.map_variable(self, expr, expn_state)
+        else:
+            return result
 
 # }}}
 
-- 
GitLab