Bug 146065

Summary: Assignment from array via a property getter suppresses value of used element in any reference to the array
Product: LibreOffice Reporter: Joshua Coppersmith <joshua_coppersmith>
Component: BASICAssignee: Not Assigned <libreoffice-bugs>
Status: UNCONFIRMED ---    
Severity: enhancement CC: joshua_coppersmith
Priority: medium    
Version: 7.2.2.2 release   
Hardware: All   
OS: All   
Whiteboard: QA:needsComment
Crash report or crash signature: Regression By:
Attachments: Simple demonstration following steps to reproduce

Description Joshua Coppersmith 2021-12-05 20:00:05 UTC
Description:
Assignment like
   Result = MyInstance.ArrayProperty(3)
will return 0 or Empty (depending on type of Result and ArrayProperty) and change the value of element with index 3 to 0 or Empty.


Steps to Reproduce:
1. Create and populate an array
2. Pass a reference to that array into a class using a setter on a Variant property
3. Assign to a type compatible with an element in that array using the getter for that array and referencing a specific element in that assignment


Actual Results:
4. All held references to the array will reflect that the element assigned FROM will be suppressed to 0/Empty
5. Assignment will result in a value of 0/Empty


Expected Results:
Assignment should result in the assigned variable taking the value/reference held as that array element and the array element itself should be left unchanged


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
The context for this behavior is difficult to explain. Please see the attached document which has taken efforts to demonstrate the behavior in a way that can be tested quickly.
Comment 1 Joshua Coppersmith 2021-12-05 20:11:01 UTC
Created attachment 176715 [details]
Simple demonstration following steps to reproduce

As outlined in the code remarks, assigning to the variable Execution will trigger a set of cases demonstrating the concern.
Comment 2 Joshua Coppersmith 2021-12-06 04:20:34 UTC
LeslieS points out that this behavior is caused by Set rather than Let in the property setter. Changed to Enhancement to see if BASIC could throw an error under these circumstances, since they could arise by Set vs. Let in setter or by Object vs. non-Object in Variant holding the array itself.