From 3f5f25c47a3bbbab2dddf43cf8f5deb84788bda5 Mon Sep 17 00:00:00 2001 From: Daniel Bauer <daniel.j.bauer@fau.de> Date: Thu, 28 Mar 2024 13:31:39 +0100 Subject: [PATCH] fix typing of contants --- src/pystencils/backend/kernelcreation/typification.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pystencils/backend/kernelcreation/typification.py b/src/pystencils/backend/kernelcreation/typification.py index 83e6ea934..9ef649b31 100644 --- a/src/pystencils/backend/kernelcreation/typification.py +++ b/src/pystencils/backend/kernelcreation/typification.py @@ -126,8 +126,15 @@ class TypeContext: raise TypificationError( f"Can't typify constant with non-numeric type {self._target_type}" ) - c.apply_dtype(self._target_type) - + if c.dtype is None: + c.apply_dtype(self._target_type) + elif deconstify(c.dtype) != self._target_type: + raise TypificationError( + f"Type mismatch at constant {c}: Constant type did not match the context's target type\n" + f" Constant type: {c.dtype}\n" + f" Target type: {self._target_type}" + ) + case PsSymbolExpr(symb): symb.apply_dtype(self._target_type) -- GitLab