Pulse Works Studio

Parse Error: Function "empty()" not found in base Array.

Array.empty() is not a Godot 4 method. The check is is_empty().

Cause

Godot 3 used empty() on arrays and several other built-ins. Godot 4 renamed those calls to is_empty() so the name cannot be confused with clearing the array. The analyzer reports the missing function on the inferred Array type.

Fix

func first_item(items: Array) -> Variant:
	if items.is_empty():
		return null
	return items[0]

Related

Godot Dev Tools is a Pulse Works Studio project. All error explainers.