diff --git a/src/pystencils/backend/kernelcreation/typification.py b/src/pystencils/backend/kernelcreation/typification.py index 9585cb23f2ea0aeae64fadb7a0cd292625234f80..1c34fac6fdbb4b78830c1c4b88f0485740475a2a 100644 --- a/src/pystencils/backend/kernelcreation/typification.py +++ b/src/pystencils/backend/kernelcreation/typification.py @@ -584,20 +584,19 @@ class Typifier: # bin op consisting of a scalar and a vector that is converted to a scalar # -> whole expression should be treated as scalar - scalar_op_tc = TypeContext() - self.visit_expr(expr.scalar_operand, scalar_op_tc) + self.visit_expr(expr.scalar_operand, tc) vector_op_tc = TypeContext() self.visit_expr(expr.vector_operand, vector_op_tc) - if scalar_op_tc.target_type is None or vector_op_tc.target_type is None: + if tc.target_type is None or vector_op_tc.target_type is None: raise TypificationError( f"Unable to determine type of argument to vector horizontal: {expr}" ) - if not isinstance(scalar_op_tc.target_type, PsScalarType): + if not isinstance(tc.target_type, PsScalarType): raise TypificationError( - f"Illegal type in scalar operand (op1) to vector horizontal: {scalar_op_tc.target_type}" + f"Illegal type in scalar operand (op1) to vector horizontal: {tc.target_type}" ) if not isinstance(vector_op_tc.target_type, PsVectorType): @@ -605,13 +604,13 @@ class Typifier: f"Illegal type in vector operand (op2) to vector horizontal: {vector_op_tc.target_type}" ) - if vector_op_tc.target_type.scalar_type is not scalar_op_tc.target_type: + if vector_op_tc.target_type.scalar_type is not tc.target_type: raise TypificationError( f"Scalar type of vector operand {vector_op_tc.target_type} " - f"does not correspond to type of scalar operand {scalar_op_tc.target_type}" + f"does not correspond to type of scalar operand {tc.target_type}" ) - tc.apply_dtype(scalar_op_tc.target_type, expr) + tc.apply_dtype(tc.target_type, expr) case PsBinOp(op1, op2): self.visit_expr(op1, tc)