godot: EditorExportPlugin raises error everytime you run the game with F5 because of "abstract native class"

Godot version

4.0 rc2

System information

Manjaro Linux using i3, Foward+

Issue description

I’ve added an ExportPlugin to my addon and everytime I run the game in the editor I know get this error:

SCRIPT ERROR: Parse Error: Class "eh_UtilitiesExportPlugin" cannot be constructed as it is based on abstract native class "EditorExportPlugin".

I even tried to guard it with an Engine.is_editor_hint() call but it doesn’t work, I still get the same error even though line 54 shouldn’t be executing: image

Weirdly enough, this guard works fine in other parts of the project, but fails here.

Steps to reproduce

Just create a script that extends EditorExportPlugin, and try to create an instance of it in an EditorPlugin script

Minimal reproduction project

See “Steps to Reproduce”

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 3
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

So the issue here is that user scripts end up trying to access Editor-only classes at runtime?

In my project, I’m not actually accessing the Editor-only classes during game runtime. However, my scripts are still loaded/parsed, and the compiler complains about it. The script code is never executed.

At least, this is what I believe to be happening, based on the fact that casting the Editor-only class to a Variant fixes the compile error, and there are no further errors during runtime.

Meanwhile, a workaround:

Casting the EditorExportPlugin-derived class to a Variant seems to trick the compiler:

	if Engine.is_editor_hint():
		_exporter = (GitVersionInjector as Variant).new()
		add_export_plugin(_exporter)

Presumably this would also work with other classes that might have this issue.

Right, it’s registered as a normal full class: https://github.com/godotengine/godot/blob/2ec0da1a75a066fe88986fc6ceda22fbabf7eedd/editor/register_editor_types.cpp#L133

But the recently added gdscript analyzer check which tries to determine if a parent class is abstract, instead only checks if it can be instantiated right now. The fact that editor types can’t be instantiated when running the project leads to the analyzer incorrectly interpreting them as being “abstract”.