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

[GDScript 2.0] Calling .append_array over TypedArrays causes error #57008

Closed
nonunknown opened this issue Jan 20, 2022 · 1 comment
Closed

[GDScript 2.0] Calling .append_array over TypedArrays causes error #57008

nonunknown opened this issue Jan 20, 2022 · 1 comment

Comments

@nonunknown
Copy link
Contributor

nonunknown commented Jan 20, 2022

Godot version

v4.0.dev.custom_build [eacde08]

System information

manjaro KDE

Issue description

When you are working with typed arrays and call .append_array() it expects an array, and not the typed array of the declared type, something like: Array[int]

Working example:

var arr:Array = []

func _ready() -> void:
	arr.append_array([1,2,3,4,5,6])
	print(arr)
	for i in range(10):
		print("Result: ", arr[randi() % arr.size()])

output:

 
[1, 2, 3, 4, 5, 6]
Result: 4
Result: 2
Result: 1
Result: 2
Result: 3
Result: 4
Result: 6
Result: 2
Result: 5
Result: 6

Not working example (FREEZE)

var arr:Array[int] = []

func _ready() -> void:
	arr.append_array([1,2,3,4,5,6])
	print(arr)
	for i in range(10):
		print("Result: ", arr[randi() % arr.size()])

NO OUTPUT, BECAUSE IT FREEZES

in a test with PR #57007 an output is provided :

func _ready() -> void:
	arr.append_array([1,2,3,4,5,6])
	print(arr)
	for i in range(10):
		print("Result: ", arr.pick_random())

output:

[]
Result: null
Result: null
Result: null
Result: null
Result: null
Result: null
Result: null
Result: null
Result: null
Result: null

Steps to reproduce

Described above

Minimal reproduction project

N/a

@cdemirer
Copy link
Contributor

Kind of a duplicate of: #54939

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

No branches or pull requests

4 participants