PassBy="value" doesn't duplicate entire structure

Description

Hi,
found that PassBy="value" do not duplicate entire structure.
If I add array to a struct, and modify that structure in a function with argument passby="value"
My array also will be modified.

will return ["John","Jason","James", "TEST"]

Tryed to do <cfset data = duplicate(data)>
Works as expected, “combination” wont be modified

Tested on coldfusion 18 with <cfapplication passarraybyreference = "true | false">
works as expected.

Environment

None

Activity

Show:
Guardian
July 13, 2020, 4:49 PM
Edited

Please add 3-rd case, when “Struct“ with “array” inside is passed to function:

 

Pothys - MitrahSoft
July 13, 2020, 8:38 PM

, I think No need. Did you see the first case? . Because, first case also have struct with array example. So, the above case as same as the first case. Please check.

Guardian
July 13, 2020, 9:11 PM

, sorry, I just saw that test passed, and that confused me.

Michael Offner
August 28, 2020, 11:57 PM

when you consult the documentation for “duplicate“ https://docs.lucee.org/reference/functions/duplicate.html you will see that the function has 2 arguments, the second is of interest for us, “deepcopy“ that one is by default to true with the function “duplicate“, but false with “passby“.

Michael Offner
August 29, 2020, 12:12 AM

Fixed

Assignee

Unassigned

Reporter

Guardian

Priority

Critical

Labels

Fix versions

Sprint

5.3.8 Sprint 3

Affects versions