Skip to content

Bugfix avoid east and west const

Here's the printing logic for SympyAsssignment:

        if node.is_declaration:
            if node.is_const # <<<  and 'const' not in self._print(node.lhs.dtype):
                prefix = 'const '
            else:
                prefix = ''
            data_type = prefix + self._print(node.lhs.dtype) + " "
            return "%s%s = %s;" % (data_type, self.sympy_printer.doprint(node.lhs),
                                   self.sympy_printer.doprint(node.rhs))
        else:
            lhs_type = get_type_of_expression(node.lhs)
            if type(lhs_type) is VectorType and isinstance(node.lhs, cast_func):

It will always prefix const on a declaration. This will not work if dtype is also const since:

    def __str__(self):
        result = BasicType.numpy_name_to_c(str(self._dtype))
        if self.const:
            result += " const"
        return result

So we get something like const int64_t const.

I deleted the postfix const to have everything nicely aligned.

Merge request reports