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

Godot v4 beta17 - Concatenating typed arrays changes the type #72590

Closed
PabloNeirotti opened this issue Feb 2, 2023 · 4 comments · Fixed by #73540
Closed

Godot v4 beta17 - Concatenating typed arrays changes the type #72590

PabloNeirotti opened this issue Feb 2, 2023 · 4 comments · Fixed by #73540

Comments

@PabloNeirotti
Copy link

Godot version

v4.0.beta17.official [c400205]

System information

Apple M1 Max - macOS Ventura 13.1 (22C65)

Issue description

I am getting an error due to functions no longer returning the correct typed array, when the function concatenates arrays and returns it.

In other words, the following fails:

func add_arrays() -> Array[ClassA]:
	var array_1: Array[ClassA] = []
	var array_2: Array[ClassA] = []
	return array_1 + array_2

Screenshot 2023-02-02 at 1 02 53 PM

I'm assuming when concatenating, the typing changes to a generic Array now? Just a guess.

Steps to reproduce

N/A

Minimal reproduction project

Godot Crash Project.zip

@PabloNeirotti
Copy link
Author

Guessing it's related to: #69248

@PabloNeirotti
Copy link
Author

PabloNeirotti commented Feb 2, 2023

I also get errors from using .filter and .map now.

For instance, the following fails:

var array_1: Array[ClassA] = []
var array_2: Array[ClassB] = array_1.map(func(obj: ClassA): return ClassB.new())

I understand this is not what you use a .map for, it's just an example. The point is I shouldn't get a Syntax error from this. One would assume that .map would return a typing different than that of the original Array and that's fine.

I guess a way to type the result could be:

var array_1: Array[ClassA] = []
var array_2: Array[ClassB] = array_1.map(func(obj: ClassA) -> ClassB: return ClassB.new())

@dalexeev
Copy link
Member

dalexeev commented Feb 2, 2023

I also get errors from using .filter and .map now.

See #72566.

@PabloNeirotti
Copy link
Author

I also get errors from using .filter and .map now.

See #72566.

Ah excellent, thank you for sharing.

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

Successfully merging a pull request may close this issue.

4 participants