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
I encountered an issue related to the instantiation of a class, which inherits from EditorPlugin. The problem arises in scenarios where, the conditional logic should prevent the instantiation of this class.
if 1 == 0: # and Engine.is_editor_hint():
_editor_camera_helper = EditorCameraHelper.new() # extends EditorPlugin. Exception is here
_camera = _editor_camera_helper.editor_cameras[0]
else:
_camera = get_tree().get_first_node_in_group(Global.Groups.Camera)
When running, I receive the error: "Class 'EditorCameraHelper' cannot be constructed as it is based on abstract native class 'EditorPlugin'". This occurs despite the fact that the conditions should prevent the execution of the code inside the if block. In the case of if 1 == 0, it's obvious that the condition is always false. Similarly, with if Engine.is_editor_hint(), this condition should return false during normal project execution.
This isn't so much a bug as it is a missing possible feature, as it seems GDScript doesn't have this kind of static conditions, but that's not necessarily a guarantee anyway, not all languages do, c++ for example does not, at least without constexpr
This is not a runtime error necessarily, but a compile time one, this class cannot be compiled no matter what the conditions are
There are also suggestions for some optimisation for this kind of cases but don't have the link right now
Godot version
v4.1.3.stable.official [f06b6836a]
System information
MacOS 14.1.1 (23B81)
Issue description
I encountered an issue related to the instantiation of a class, which inherits from EditorPlugin. The problem arises in scenarios where, the conditional logic should prevent the instantiation of this class.
When running, I receive the error: "Class 'EditorCameraHelper' cannot be constructed as it is based on abstract native class 'EditorPlugin'". This occurs despite the fact that the conditions should prevent the execution of the code inside the if block. In the case of if 1 == 0, it's obvious that the condition is always false. Similarly, with if Engine.is_editor_hint(), this condition should return false during normal project execution.
Steps to reproduce
Run project
Minimal reproduction project
GodotAllBugs.zip
The text was updated successfully, but these errors were encountered: