Bug modifier_eval() failing with some negative numbers

Crowther

Active member
Really weird bug. It still happens in r28727 (I suspected r28728 at first). It happens in other clan members KoLmafia.

Doing "ash modifier_eval("-23963")"
aborts with "Expression evaluation error: Index -1 out of bounds for length 128 () Returned: void"
Doing "ash modifier_eval("-23960")"
returns "-23960"
 
It looks like it fails on working with expressions with literal values -23963, -23964, or -23968 because of weird shenanigans the expression parser does when converting these specific values to its internal representation.

Essentially, they end up getting mapped to the symbols for greater-than-or-equal, less-than-or-equal, and not-equal-to. The number-to-internal-value mapping is carefully chosen to avoid most of the symbols used to represent special operations in the parse tree, but these particular operations are represented with Unicode symbols far from the range the other symbols live in.
 
Back
Top