diff --git a/src/language/node_processor/IfProcessor.hpp b/src/language/node_processor/IfProcessor.hpp
index 1a76e3068dcb6bd29f4e4e250dc3d6cc1f9f6d41..18d87bb89f11ee0f335fe0637f4569dc5b3cab15 100644
--- a/src/language/node_processor/IfProcessor.hpp
+++ b/src/language/node_processor/IfProcessor.hpp
@@ -3,6 +3,7 @@
 
 #include <language/ast/ASTNode.hpp>
 #include <language/node_processor/INodeProcessor.hpp>
+#include <language/utils/SymbolTable.hpp>
 
 class IfProcessor final : public INodeProcessor
 {
@@ -39,8 +40,7 @@ class IfProcessor final : public INodeProcessor
       }
     }
 
-    if (m_node.children[0]->m_symbol_table != m_node.m_symbol_table)
-      m_node.children[0]->m_symbol_table->clearValues();
+    Assert(m_node.children[0]->m_symbol_table == m_node.m_symbol_table);
     return {};
   }
 
diff --git a/tests/test_IfProcessor.cpp b/tests/test_IfProcessor.cpp
index ccade16253ae5b1024a97cc5ba038ec222bf5156..71fc766845d22090e319ea02f071e8707d72eed5 100644
--- a/tests/test_IfProcessor.cpp
+++ b/tests/test_IfProcessor.cpp
@@ -102,6 +102,30 @@ if(false) {
     CHECK_IF_PROCESSOR_RESULT(data, "i", 2ul);
   }
 
+  SECTION("simple if(true) with local variable")
+  {
+    std::string_view data = R"(
+let i:N, i = 0;
+if(true) {
+  let j:N, j = 1;
+  i = j;
+}
+)";
+    CHECK_IF_PROCESSOR_RESULT(data, "i", 1ul);
+  }
+
+  SECTION("simple if(false) with else local variable")
+  {
+    std::string_view data = R"(
+let i:N, i = 0;
+if(false) {} else {
+  let j:N, j = 1;
+  i = j;
+}
+)";
+    CHECK_IF_PROCESSOR_RESULT(data, "i", 1ul);
+  }
+
   SECTION("errors")
   {
     SECTION("bad test type")