• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: SVC-1356
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Babbage Linden
Reporter: Radian Artaud
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
2. Second Life Service - SVC

Mono Beta treats list assignments as references.

Created: 30/Jan/08 12:07 PM   Updated: 06/Mar/08 03:41 PM
Return to search
Component/s: Scripts
Affects Version/s: Mono Beta
Fix Version/s: None

Issue Links:
Relates
 

Linden Lab Issue ID: DEV-9843


 Description  « Hide
Assinging one list variable to another list variable copies only the list's reference instead of creating an identical copy of the list. As a result, changes to one list affects the other. The following script demonstrates the issue:

default {
state_entry() {}

touch_start(integer total_number) { list theList; theList = [0x637c777b, 0xf26b6fc5, 0x3001672b, 0xfed7ab76]; list theListCopy; theListCopy = theList; theList += [0xfed7ab76]; llOwnerSay("theList Length: " + (string)llGetListLength(theList)); llOwnerSay("theListCopy Length: " + (string)llGetListLength(theListCopy)); }
}

When run as LSL it outputs:
Object: theList Length: 5
Object: theListCopy Length: 4

When run as MONO it outputs:
Object: theList Length: 5
Object: theListCopy Length: 5



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Thraxis Epsilon added a comment - 30/Jan/08 07:22 PM
I can confirm this. My test script is below:

list origin =["1","2","3","4"];
list destination=[];

default
{
state_entry()

{ destination = origin; llOwnerSay(llList2CSV(destination)); origin += ["5"]; llOwnerSay(llList2CSV(destination)); destination += ["6"]; llOwnerSay(llList2CSV(origin)); llSetTimerEvent(1); }

timer()

{ origin += ["7"]; llOwnerSay(llList2CSV(destination)); destination += ["8"]; llOwnerSay(llList2CSV(origin)); llSetTimerEvent(0); }

}

Expected Output:
[19:21] Object: 1, 2, 3, 4
[19:21] Object: 1, 2, 3, 4
[19:21] Object: 1, 2, 3, 4, 5
[19:21] Object: 1, 2, 3, 4, 6
[19:21] Object: 1, 2, 3, 4, 5, 7

Actual Output:
[19:22] Object: 1, 2, 3, 4
[19:22] Object: 1, 2, 3, 4, 5
[19:22] Object: 1, 2, 3, 4, 5, 6
[19:22] Object: 1, 2, 3, 4, 5, 6, 7
[19:22] Object: 1, 2, 3, 4, 5, 6, 7, 8


Thraxis Epsilon added a comment - 30/Jan/08 07:29 PM
As an update.... The following code WILL create a new list and work correctly:

list origin =["1","2","3","4"];
list destination=[];

default
{
state_entry()

{ destination = llList2List(origin,0,-1); llOwnerSay(llList2CSV(destination)); origin += ["5"]; llOwnerSay(llList2CSV(destination)); destination += ["6"]; llOwnerSay(llList2CSV(origin)); llSetTimerEvent(1); }

timer()

{ origin += ["7"]; llOwnerSay(llList2CSV(destination)); destination += ["8"]; llOwnerSay(llList2CSV(origin)); llSetTimerEvent(0); }

}


Thraxis Epsilon added a comment - 30/Jan/08 07:42 PM
Passing lists to a function is done by reference as well.

listByReference(list destination)
{
destination += ["5"];
destination += ["6"];
destination += ["7"];
destination += ["8"];
}

default
{
state_entry()

{ list origin =["1","2","3","4"]; listByReference(origin); llOwnerSay(llList2CSV(origin)); }

}


Radian Artaud added a comment - 31/Jan/08 02:16 PM
Quite honestly, I would rather have this functionality or atleast somehow have reference asignments in LSL, but I highly doubt this was intended.

Aster Lardner added a comment - 05/Feb/08 12:56 AM
I think this is probably the same bug...

list list_A = ["one", "two", "three"];
list list_B = ["1", "2", "3"];
default
{
state_entry()

{ llSay(0, llList2CSV(list_A)); llSay(0, llList2CSV(list_B)); llSay(0, llList2CSV(list_A + list_B)); llSay(0, llList2CSV(list_A)); llSay(0, llList2CSV(list_B)); }

}

The second time list_A prints, it's now "one, two, three, 1, 2, 3" instead of just "one two three."


Periapse Linden added a comment - 06/Mar/08 03:05 PM
This was fixed with the value semantics update. It has passed QA so I'm marking as resolved.