/list scope from inheritance is lost immediately after it's been passed via return() instead of the line afterward.
Numbered Steps to Reproduce Problem:
Only seems to happen if inheritance is involved. Works fine if the same list hasn't been passed down from child to parent.
Code Snippet (if applicable) to Reproduce Problem:
world
icon_size = 32 // 32x32 icon size by default
view = 6 // show up to 6 tiles outward from center (13x13 view)
mob
verb/TestListScopeByReturn()
var/obj/childofObj/grandChildOfObj/testObject = new(loc)
var/list/testList = list("Eenie","Menie","Miney","Moe")
var/list/receivedList = testObject.ReturnList(testList)
if (receivedList == null)
usr << "Null list received."
else
usr << "List received length [receivedList.len]"
for (var/thisItem in receivedList)
usr << thisItem
obj
proc/ReturnList(var/list/thisList)
world << "[type].thisList.len [thisList.len]"
return(thisList)
obj/childOfObj
ReturnList(var/list/thisList)
world << "[type].thisList.len [thisList.len]"
..(thisList)
obj/childofObj/grandChildOfObj
ReturnList(var/list/thisList)
world << "[type].thisList.len [thisList.len]"
..(thisList)
Expected Results:
Variable received by receivedList is the list. Snippet above would then report list length and each member of the list.
Actual Results:
Variable received by receivedList is null. Snippet above reports it as null.
Does the problem occur:
Every time? Or how often?
Does indeed seem to happen every time. Sometimes I seem to get away with it, but it may be due to the levels of inheritance involved in that instance.
In other games?
Unknown.
In other user accounts?
Unknown.
On other computers?
Unknown.
When does the problem NOT occur?
If I remove inheritance, it works fine. Replace line 9 with:
var/obj/testObject = new(loc)
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:
Don't use inheritance when returning values. Somewhat limiting in what you can do, but hey, a bug's a bug.