Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the class_name of a subclass results in spurious 'nonexistent function' errors at runtime #81548

Closed
tcoxon opened this issue Sep 11, 2023 · 2 comments · Fixed by #81577
Closed

Comments

@tcoxon
Copy link
Contributor

tcoxon commented Sep 11, 2023

Godot version

4.2-dev4

System information

Godot v4.2.dev4 - Arch Linux #1 SMP PREEMPT_DYNAMIC Sat, 10 Jun 2023 00:35:35 +0000 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (nvidia; 530.41.03) - AMD Ryzen 5 2600 Six-Core Processor (12 Threads)

Issue description

I tried updating a project from Godot 4.1 to 4.2 using the dev snapshot and encountered this issue.

One of my editor plugins has a class called 'Table', that both preloads and uses the class_name of one of its subclasses (let's call it DerivedTable). This seems to trigger a bug in 4.2 that wasn't present in 4.1. At runtime, the engine reports an error that a static function doesn't exist, when it clearly does.

From the attached reproducer:

table.gd:

extends Resource
class_name Table

static func from_directory(path: String, extension := "tres"):
	return preload("derived_table.gd").some_method()

static func from_array(array: Array):
	var table := DerivedTable.new()
	table.set_data(array)
	return table

derived_table.gd:

extends Table
class_name DerivedTable

static func some_method():
	pass

Then when you call Table.from_directory(""), the engine reports:

SCRIPT ERROR: Invalid call. Nonexistent function 'from_directory' in base 'GDScript'.

Steps to reproduce

  1. Run the attached reproduction project.

Minimal reproduction project

Reproducer

@dalexeev
Copy link
Member

dalexeev commented Sep 12, 2023

[7d29ac0] GDScript: solve _populate_class_members() cyclic dependency problem

Regression from #79205. See also #81447. CC @anvilfolk

@anvilfolk
Copy link
Contributor

Thank you for the heads up, @dalexeev, and @tcoxon MRP! Will take a look when I have some time!

Now that cyclic dependency bugs in compilation steps are fixed, it seems like a lot of things were relying on the previous solution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants