ID:2383704
 
Resolved
Changes to the way the + operator optimized expressions that included constants resulted in bad code output in some cases.
BYOND Version:512.1436
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Firefox 61.0
Applies to:Dream Maker
Status: Resolved (512.1437)

This issue has been resolved.
Descriptive Problem Summary:

Compiler bug. Performing an addition "1 + (1 == 1)" on the result of a comparison (equality, "<", &c.) causes alternately that statement to not be processed or the constant side of the addition to be ignored.

Only occurs if the constant is on the LEFT-HAND side of the addition. Appears to apply only to addition as far as I can tell in a few quick tests.

Code Snippet (if applicable) to Reproduce Problem:
/client/New()
..()

src << "A: [4 + (1 == 1)]"
var/b = 4 + (1 == 1)
src << "B: [b]"


Expected Results:

A: 5
B: 5

Actual Results:

B: 1

Does the problem occur:
Every time? Or how often? Every time.
In other games? Yes, in a test project.
In other user accounts? Unknown.
On other computers? Unknown.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)

New in 512.1436

Workarounds:

Don't put constants on the LHS of additions which involve comparisons.
Lummox JR resolved issue with message:
Changes to the way the + operator optimized expressions that included constants resulted in bad code output in some cases.
Good catch. My testing didn't catch anything like this but once I saw the problem in action the error in the logic revealed itself.

The other operators that were changed shouldn't have this problem; addition is a special case because it's optimizing both numbers and strings.