-
-
Notifications
You must be signed in to change notification settings - Fork 23.5k
Open
Labels
Description
Tested versions
- Reproducible since 4.1-dev2
System information
Godot v4.3.dev2 - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1650 SUPER (NVIDIA; 31.0.15.4617) - Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz (6 Threads)
Issue description
The way static variables are handled in GDScript differ from other programming languages, where they're not inherited to children GDScript classes. Instead, the parent class controls the static variables of all children.
Steps to reproduce
The MRP has the following structure:
Parent.gd
class_name Parent
extends Node
static var PROPERTY_1 : int
static var PROPERTY_2 : String
Child1.gd
class_name Child1
extends Parent
static func _static_init():
PROPERTY_1 = 10
PROPERTY_2 = "Child1"
Child2.gd
class_name Child2
extends Parent
static func _static_init():
PROPERTY_1 = 5
PROPERTY_2 = "Child2"
Main.gd
extends Node2D
func _ready():
print(Child1.PROPERTY_1)
print(Child1.PROPERTY_2)
print(Child2.PROPERTY_1)
print(Child2.PROPERTY_2)
Main.gd is included in the main scene.
The assumption goes that the result in the console would look like this
10
Child1
5
Child2
But instead it prints the following.
5
Child2
5
Child2
Minimal reproduction project (MRP)
haydads