ID:958140
 
(See the best response by DarkCampainger.)
Descriptive Problem Summary:
/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.
Best response
You're not returning the value returned by the call to the parent process, so it's returning null. You need to do this:

obj/childOfObj

ReturnList(var/list/thisList)

world << "[type].thisList.len [thisList.len]"

return ..(thisList)

obj/childofObj/grandChildOfObj

ReturnList(var/list/thisList)

world << "[type].thisList.len [thisList.len]"

return ..(thisList)
DarkCampainger resolved issue (Not a bug)
Of course it was obvious thing I was doing wrong, thanks for pointing that out that if I'm calling the top-level child proc of course that's the proc that's going to need to be returning.
Glad to help. For the future, it's usually a good idea to post in Developer Help first to make sure it's an actual bug and not a misunderstanding or mistake.
In response to DarkCampainger
I bumped it on over there, 'twas indeed my bad. Maybe some of the fellow coding newbs will learn from my mistakes. It's not the first time I made this mistake, I think I'm a bit rusty.