Version: 513.1536
When code following a certain pattern involving the `?.` and `+=` operators with a negative literal value is compiled, the resulting executable actually tries to add `null` to the left-hand-side instead of the correct number.
It happens with "-=" as well (and potentially others.)
Numbered Steps to Reproduce Problem:
1) Run the snippet
Code Snippet (if applicable) to Reproduce Problem:
/datum
var/info
/world/New()
// Shows the bug not decrementing the number
world.log << "FIRST TEST"
var/datum/x = new
x.info = 1337
world.log << "Value before: [x.info]"
x?.info += -1
world.log << "Value after: [x.info]"
// Shows the bug placing `null` into an empty list.
world.log << "\nSECOND TEST"
var/datum/y = new
y.info = list()
world.log << "Length before: [length(y.info)]"
y?.info += -1
world.log << "Length after: [length(y.info)]"
world.log << "First entry == null: [y.info[1] == null]"
Expected Results:
First block of code: The `x.info` field should become `1336`
Second block of code: The list at `y.info` should have `-1` appended to it.
Actual Results:
First block of code: The `x.info` field does not change.
Second block of code: The list at `y.info` has `null` appended to it.
Does the problem occur:
It occurs every time as long as the code follows the pattern `x?.y += -literal`
When does the problem NOT occur?
Switching `?.` for `.`, or making sure the literal is positive stops the problem from happening.