Skip to content
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

Two different export arrays will be shared if they are initialized to same value #36526

Closed
cccccroge opened this issue Feb 25, 2020 · 2 comments
Labels

Comments

@cccccroge
Copy link

**Godot version: 3.2

**OS/device including version: Windows 10

Issue description:
If two different export array variables are initialized to same value when declared,
modify one of them will affect the other unexpectedly.

I'm not sure if this is the same behavior as the doc says, although what it says is this will happen between instances using same script, not between two variables in same script. I treat it as a different problem.

exported arrays are shared between all instances. This means that editing them in one instance will cause them to change in all other instances Ref

Steps to reproduce:

  1. Add a node2D as main scene
  2. Attach script as follow:
extends Node2D

export(Array, int) var A = [1, 2, 3]
export(Array, int) var B = [1, 2, 3]

func _ready():
	print(A)
	print(B)
	A[0] = 0
	print(A)
	print(B)
  1. Run the scene and it outputs:
[1, 2, 3]
[1, 2, 3]
[0, 2, 3]
[0, 2, 3]

Minimal reproduction project:
array_bug.zip

@cccccroge
Copy link
Author

possibly duplicate of #36520

@Calinou
Copy link
Member

Calinou commented Feb 25, 2020

This is actually a duplicate of #20436.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants