Asc() and ternary mess with Evaluator's basic calculus

This Evaluator function (unsurprisingly) prints 65 and 66 or - if we press Ctrl - 65 and 64:

rev = KeyDown("ctrl");

d = 65;
// d = Asc("A");

i = d + (rev ? -1 : 1);

Output("d = " + d);
Output("i = " + i);

Output("");

Now look what happens if we use Asc() to define d and press Ctrl:

Not something we need so close to the finals :wink:


Update: Looks like Asc() is the main culprit here. Forcing a conversion to integer seems to fix the problem:

d = Asc("A") As int;

Using if-else instead of ternary will work for a while and then fail if Asc() is not converted to int.

It's not as strange as it looks, although I agree it's either a bug or something that needs documenting. :slight_smile:

Asc is returning an unsigned type, so it underflows when representing negative numbers.

Fixed for the next update. Thanks for the report!