Bug 146065 - Assignment from array via a property getter suppresses value of used element in any reference to the array
Summary: Assignment from array via a property getter suppresses value of used element ...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
7.2.2.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard: QA:needsComment
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-05 20:00 UTC by Joshua Coppersmith
Modified: 2021-12-21 04:06 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Simple demonstration following steps to reproduce (11.11 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-12-05 20:11 UTC, Joshua Coppersmith
Details

Note You need to log in before you can comment on or make changes to this bug.
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.