C#: Adding = new Array<int>()
when declaring an int array Export, makes 0 be considered a null value instead of 0
#98309
Labels
Milestone
Tested versions
4.3 stable, as well as 4.3.dev5
System information
Godot v4.3.stable.mono - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 SUPER (NVIDIA; 32.0.15.6081) - AMD Ryzen 9 3900X 12-Core Processor (24 Threads)
Issue description
In C#, using
Godot.Collections.Array<int>
, I ran into the following obscure issue. My habit when declaring class variables is usually to initialize them, so I did so like this:After doing so, I initialized the array in the editor and added a value of 0 to it. However, upon running
includedPanels.Contains(0)
on it, I was surprised that it returned false.Eventually, I realized that the 0 was actually being stored as null. Bizarrely, I figured out that, if I remove the
= new Array<int>()
, then rebuild the project and re-initialize the array, then the 0 is actually stored as 0. I changed my declaration like so, before building, resetting the array in the editor, and initializing it again:And this produced the following change (screenshot from my Git client):

Steps to reproduce
Create a class and attach its script to a node.
Add the following properties to the class:
Build the project, and then, in the editor, click on the node the script is attached to. Initialize both arrays with a value of 0. Open the scene file in a text editor, and you will see that the first contains
0
and the other containsnull
.Minimal reproduction project (MRP)
N/A
The text was updated successfully, but these errors were encountered: