ID:2684901
 
Resolved
Changing src in a proc by assigning a new value could cause some subsequent var accesses from src to happen incorrectly, by the compiler assuming src hadn't changed.
BYOND Version:513
Operating System:Windows 10 Home 64-bit
Web Browser:Chrome 90.0.4430.212
Applies to:Dream Maker
Status: Resolved (514.1555)

This issue has been resolved.
Descriptive Problem Summary:
the first line after assigning a new src using a variable as an index will apply the variable change to the old src

Numbered Steps to Reproduce Problem:
see snippet

Code Snippet (if applicable) to Reproduce Problem:
mob
var
list/testStatusEffects = list()
obj/testObj/testMain = new

New()
..()
testStatusEffects["ID"] = testMain

verb
testThis()
new /obj/testObj(loc, src)

obj
testObj
var
testMerge
testID = "ID"

New(loc, mob/M)
var/obj/testObj/inisource = src
if(M)
world.log << "1testVar = ([testMerge]), isrc ([inisource.testMerge])" // should be null, null
//src = M.testStatusEffects["ID"] // this works
src = M.testStatusEffects[testID] // this doesn't work
testMerge = 1
world.log << "2testVar = ([testMerge]), isrc ([inisource.testMerge])" // should be 1, null
testMerge = 1
world.log << "2testVar = ([testMerge]), isrc ([inisource.testMerge])" // should be 1, null


Expected Results:
variable assignments apply to proper object

Actual Results:
first line of variable assignment applies to old object

Does the problem occur:
Every time? Or how often?
In other games?
In other user accounts?
On other computers?

When does the problem NOT occur?

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.)

Workarounds:
adding some kinds of spacer "fixes" it, such as outputting to world.log directly after the new src assignment

Lummox JR resolved issue with message:
Changing src in a proc by assigning a new value could cause some subsequent var accesses from src to happen incorrectly, by the compiler assuming src hadn't changed.