godot icon indicating copy to clipboard operation
godot copied to clipboard

The name specified in class_name cannot be used as const.

Open Juna-Idler opened this issue 2 years ago • 2 comments

Godot version

v4.2.beta2.official [f8818f85e]

System information

Godot v4.2.beta2 - Windows 10.0.22621 - Vulkan (Forward+) - integrated AMD Radeon(TM) Graphics (Advanced Micro Devices, Inc.; 31.0.21902.5) - AMD Ryzen 5 5600G with Radeon Graphics (12 Threads)

Issue description

The name specified in class_name cannot be used as const.

Steps to reproduce

An error occurs in "new_script.gd" of the following test project.

Minimal reproduction project

new_script.zip

Juna-Idler avatar Oct 20 '23 22:10 Juna-Idler

  • See also #33531.

dalexeev avatar Nov 20 '24 07:11 dalexeev

Still valid in 4.4. The code in MRP for easier overview:

class_name TestClass

const Other_preload_Class := preload("res://other_class.gd")

class Inner:
	pass

const TEST : Array[GDScript] = [
	Inner,
	OtherClass,	# Error
	OtherClass.Inner,
	Other_preload_Class,
	Other_preload_Class.Inner,
]

OtherClass is a class_name and it's the only line that causes errors. Inner classes and preloaded scripts work correctly.

KoBeWi avatar Feb 23 '25 10:02 KoBeWi