From 896d4c53a39c029fb35c861351a0a07868c30f4b Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <wry.git@bumiller.com>
Date: Sun, 1 Feb 2015 12:12:25 +0100
Subject: [PATCH] fix backward propagateSideEffect impl

---
 ast.cpp | 5 +++--
 ast.h   | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/ast.cpp b/ast.cpp
index 58ed660..96d9e2f 100644
--- a/ast.cpp
+++ b/ast.cpp
@@ -24,9 +24,10 @@ ast_node::~ast_node()
 }
 
 /* weight and side effects */
-void ast_node::propagateSideEffects(ast_node *other) const
+void ast_node::propagateSideEffects(const ast_node *other)
 {
-    other->m_side_effects = m_side_effects;
+    if (other->m_side_effects)
+        m_side_effects = true;
 }
 
 /* General expression initialization */
diff --git a/ast.h b/ast.h
index 04f8c0e..b305dac 100644
--- a/ast.h
+++ b/ast.h
@@ -110,7 +110,7 @@ struct ast_node
     bool             m_keep_node;
     bool             m_side_effects;
 
-    void propagateSideEffects(ast_node *other) const;
+    void propagateSideEffects(const ast_node *other);
 };
 
 #define ast_unref(x) do        \
-- 
2.39.5