Template bug? Negative numbers raised to the power of a variable

Before I report this as a bug, am I missing something silly?

{% set z = 0 %}
minus one to the power zero: {{ -1**0 }}
minus one to the power one: {{ -1**1 }}
minus one to the power z:   {{ -1**z }}
two to the power z:          {{ 2**z }}

Anything raised to the power zero should be one. It seems that -1**z always returns -1, and:

{% set z = 2 %}
{{ (-2)**z }}  # returns -4, incorrectly
{{ (-2)**2 }}  # returns 4, correctly

Looks like a bug to me.

Cheers, raised:

Looks like an upstream Jinja issue though:

1 Like