diff --git a/pystencils/astnodes.py b/pystencils/astnodes.py
index 7991f4780ba2ed89f06fa72faaed8eb86b0406ae..ed03bf7627040093167a175ec0229a17a484fe44 100644
--- a/pystencils/astnodes.py
+++ b/pystencils/astnodes.py
@@ -573,7 +573,7 @@ class SympyAssignment(Node):
     def __is_declaration(self):
         from pystencils.typing import CastFunc
         if isinstance(self._lhs_symbol, CastFunc):
-            assert False, f'{self._lhs_symbol} should not be a CastFunc'
+            return False
         if any(isinstance(self._lhs_symbol, c) for c in (Field.Access, sp.Indexed, TemporaryMemoryAllocation)):
             return False
         return True