KScript docs
EN

Error codes

KS6023

A minus in front of a power. The power is worked out first, so -2 ** 2 is -(2 ** 2), which is -4, as in maths and Python. Many readers expect 4, so brackets should say which is meant:

<let name="loss" value="-(2 ** 2)" /> <!-- -4 because the brackets square 2 first -->
<let name="square" value="(-2) ** 2" /> <!-- 4 because the brackets square -2 -->
$loss = -(2 ** 2)             // -4 because the brackets square 2 first
$square = (-2) ** 2           // 4 because the brackets square -2

Two fixes write the brackets: Write -(2 ** 2) keeps today's value and Write (-2) ** 2 raises the negative number. Brackets round the whole power, as in -($side ** 2), are already clear and aren't flagged.

Edit this page on GitHub