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: Don't make array literal typed in weak type context #81332

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Sep 5, 2023

We have an implicit treatment of an array literal as typed in a typed context. For example:

var a: Array
a = [1, 2, 3] # Untyped array.

var b: Array[int]
b = [1, 2, 3] # Typed array.

However, I noticed that this also happens in the case of a weak type:

var a: Array[int]
var b = a # b is "weak Array[int]".
b = [1, 2, 3] # Typed array.

Note: This may break code for users relying on this behavior, but I believe it's worth it, the current behavior is weird.

Copy link
Member

@adamscott adamscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by the GDScript team. A non-typed variable should be treated as a Variant, not as a weak typed array.

Thanks again @dalexeev for your hard work!

@akien-mga akien-mga merged commit 712ebe7 into godotengine:master Sep 20, 2023
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

3 participants