-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dictionary duplicate(deep=true) creates shallow copy #37162
Comments
The
And finally, the commit you mentioned, d280b14 was added on the very next day. It disabled Resource duplication from |
Is the intention to only deep-copy Resources, and shallow-copy other Objects? We should document that it's not currently implemented, or remove the parameter from the GDScript API until it is. The current behavior is very surprising. Or should I say, I was very surprised :) |
I feel that the best solution is to document that the deep parameter affects only the copying of dictionaries and arrays. There are too many object types one would prefer to not have duplicated by mistake, especially some types of Resources. |
* Added additional clarification for the function of the 'deep' parameter in the Dictionary's `duplicate` method.
* Added additional clarification for the function of the 'deep' parameter in the Dictionary's `duplicate` method. (cherry picked from commit 469b7c9)
Godot version: 3.2
OS/device including version: Arch Linux (i7-6700, GTX 1070, nvidia driver 440.59-7)
Issue description:
Is
duplicate(true)
intended to make a deep copy? The parameter is undocumented, but if the dictionary contains Objects, it actually makes a shallow copy, likeduplicate(false)
. If this is intended, then the documentation should explain that. (And maybe the parameter should be renamed.) If it's intended to be a deep copy, then the Objects in the dictionary should be copied.I wonder if d280b14 is related; it commented out the part of
Variant::duplicate
that checks thedeep
flag.Steps to reproduce:
Try this:
It prints:
I'd expect it to print:
Minimal reproduction project: Just paste the above code into any project. Nothing else is needed.
The text was updated successfully, but these errors were encountered: