When using the chained dot operator, some strange behavior can be observed when using lists. From what I can tell, the list needs to be of a datum that has a reference to another datum. If you call a proc on the child datum and pass another child element that exists in that list, the proc will be called on that element instead.
Code Snippet (if applicable) to Reproduce Problem:
TestChild
proc
PrintSelf()
world << "I am object \ref[src]!"
TestItem
var
TestChild/child = new
mob
verb
TestChain()
var/list/TestItem/datumList = newlist(/TestItem, /TestItem, /TestItem)
world << "By Variable:"
world << "Element 3 is \ref[datumList[3].child]"
var/TestChild/testChild = datumList[3].child
testChild.PrintSelf()
testChild.PrintSelf("test argument", "test argument")
testChild.PrintSelf("test argument", datumList[1].child)
world << "By Chain:"
world << "Element 3 is \ref[datumList[3].child]"
datumList[3].child.PrintSelf()
datumList[3].child.PrintSelf("test argument", "test argument")
datumList[3].child.PrintSelf("test argument", datumList[1].child)
Expected Results:
All output from the above should be the same.
Actual Results:
Output using the chain operator, while passing a child element, is different.
E.g.
By Variable:
Element 3 is [0x21000006]
I am object [0x21000006]!
I am object [0x21000006]!
I am object [0x21000006]!
By Chain:
Element 3 is [0x21000006]
I am object [0x21000006]!
I am object [0x21000006]!
I am object [0x21000002]!
This happens regardless of the number of arguments passed, or the position of the argument. However, it seems to always take the last instance of one of these if there are multiple.
Does the problem occur:
Every time? Or how often?
Every time
Workarounds:
You can assign the list member to a variable as seen above, and there will be no problem.