From d4a8419b604c61cace4b1e0f1e737657e17e0882 Mon Sep 17 00:00:00 2001
From: Michael Kuron <mkuron@icp.uni-stuttgart.de>
Date: Mon, 15 Jun 2020 18:29:28 +0200
Subject: [PATCH] add_types: only re-enable double-write check if it was
 previously enabled

---
 pystencils/transformations.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pystencils/transformations.py b/pystencils/transformations.py
index 448991a84..5b44eb3e1 100644
--- a/pystencils/transformations.py
+++ b/pystencils/transformations.py
@@ -954,6 +954,7 @@ def add_types(eqs, type_for_symbol, check_independence_condition):
             check.scopes.push()
             # Disable double write check inside conditionals
             # would be triggered by e.g. in-kernel boundaries
+            old_double_write = check.check_double_write_condition
             check.check_double_write_condition = False
             false_block = None if obj.false_block is None else visit(
                 obj.false_block)
@@ -961,7 +962,7 @@ def add_types(eqs, type_for_symbol, check_independence_condition):
                 obj.condition_expr, type_constants=False),
                 true_block=visit(obj.true_block),
                 false_block=false_block)
-            check.check_double_write_condition = True
+            check.check_double_write_condition = old_double_write
             check.scopes.pop()
             return result
         elif isinstance(obj, ast.Block):
-- 
GitLab