RESOLVED:The modulo operator does not get interpreted correcty as an index

I have a script that uses a modulo inside an index. Here is a sample of my code which throws an index out of range error:

previous_note = all_notes[-me.parent(1).digits%4]

In this case, me.parent(1).digits is 1. If I try this, I don’t get an error:

previous_note = all_notes[-me.parent(1).digits]

I shouldn’t get an error, as 1%4 = 1. For some reason, if I set me.parent(1).digits%4 as a variable, it does work. This code doesn’t throw an error:

index = me.parent(1).digits%4
previous_note = all_notes[-index]

This seems like a bug in the way td interprets modulos.

Thanks we are investigating.

EDIT:

Looks like you need to include parenthesis to get the correct order of operations:

v = 1
print( - (v%4) )  #returns -1
print( -v%4)      #returns  3, causing your error

Cheers.