This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes


I've just run into a strange issue I believe might be a bug.

I'm adding the result returned by load() to an array. And it destroys the array in the case if it is null.

func gui_classes():
    var classes = []
    var C = load( "res://...." ) # Here C is null. I.e. path seems not being a valid one.
    classes.push_back( C ) # At this line "classes" variable changes type from an Array to Null. It is not an Array anymore, it is literally a Null.
    return classes # And returns null

But if I simply hardcode null:

func gui_classes():
    var classes = []
    var C = null
    classes.push_back( C ) # Now it is fine, classes = [null], an array with one null element.
    return classes # And returns an Array

It doesn't seem to me it is an expected behavior. Right?

My Godot version is 3.2.2 built from source. Is it a bug or a feature?

in Engine by (43 points)

1 Answer

0 votes

I cannot confirm that. Both of your examples return an array! However, the former returns an array containing a null-object (created by load) and the latter returns an array containing a null-variable.

by (10,634 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.