You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In GDScript 2.0, attempting to assign to a subclass member variable with a type of another script's subclass quietly fails, resulting in a null value instead.
Steps to reproduce
A minimal example project is provided. In addition, here are the steps used to manually reproduce the issue:
Create a project in the latest alpha build of Godot 4.0.
Create two scripts, AScript.gd and BScript.gd, with these contents, respectively:
# BScript.gdextendsNode# Assign this script to the main scene to reproduceclassBSubClass:
# The type annotation here is what triggers the bug - without it, no problemvara:=AScript.ASubClass.new()
func_ready():
# Lone ASubClass, works as expected.varlone_a:=AScript.ASubClass.new()
print(lone_a.data)
# BSubClass.new() initializes correctly, `a` is valid, as is `data`varb:=BSubClass.new()
print(b.a.data)
# Here's where it gets weird - despite being functionally identical # to line 10, `a` is `null` after this statementb.a=AScript.ASubClass.new()
print(b.a)
# print(b.a.data) Error, `a` is null
The console output of this project is:
4
4
null
(Given that removing the type annotation from BSubClass resolves this, it seems like a type checking issue. I've used this to work around the bug in my own project.)
Godot version
v4.0.alpha8.official [cc3ed63]
System information
Windows 10
Issue description
(I tried my best with the title, I swear.)
In GDScript 2.0, attempting to assign to a subclass member variable with a type of another script's subclass quietly fails, resulting in a
null
value instead.Steps to reproduce
A minimal example project is provided. In addition, here are the steps used to manually reproduce the issue:
AScript.gd
andBScript.gd
, with these contents, respectively:The console output of this project is:
(Given that removing the type annotation from
BSubClass
resolves this, it seems like a type checking issue. I've used this to work around the bug in my own project.)Minimal reproduction project
GDScriptBugTest.zip
The text was updated successfully, but these errors were encountered: