Skip to content

GDScript 2.0: Nonexistent function 'new' in base 'GDScript' when class used first in built-in script #58957

@h0lley

Description

@h0lley

Godot version

4.0-alpha4

System information

Ubuntu, Nvidia, Vulkan

Issue description

Calling new() on a GDSscript that has been registered via class_name causes the aforementioned error when the class is referenced first in an built-in script.

When the class has been extended or instantiated beforehand, the error does not occur.
The error does also not occur when the GDSscript is loaded via loador preload.

Steps to reproduce

  1. Create a blank project
  2. Create a new script with contents:
extends Node
class_name MyClass
  1. Create a new scene, add any kind of root node and attach a built-in script with contents:
extends Node

func _ready():
	MyClass.new()
  1. Press F6 and notice error log:

Invalid call. Nonexistent function 'new' in base 'GDScript'.

Minimal reproduction project

godot_4_gdscript_new_bug.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions