Skip to content

Using method name without class fails to create static callable #86032

@IceflowRE

Description

@IceflowRE

Godot version

v4.2.stable.official [46dc277]

Using external editor Visual Code.

System information

Windows 11

Issue description

I preload a script from a @tool script where i try to call a static from another static function.

Resulting error:

res://non_tool.gd:8 - Invalid get index 'compare_ascending' (on base: 'Nil').

Steps to reproduce

Minimal example attached.


Code used:

non_tool.gd

extends RefCounted

static func compare_ascending(lhs: String, rhs: String) -> bool:
	return lhs < rhs

static func get_engine_components() -> Array[String]:
	var engine_components: Array[String] = ["b", "c", "foo", "d"]
	engine_components.sort_custom(compare_ascending)
	return engine_components

Control.gd

@tool can also be removed and is not required for it to fail.

@tool
extends Control

const NonTool := preload("non_tool.gd")


func _init():
	print(NonTool.get_engine_components())

Minimal reproduction project

invalid_index_base_nil.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