godotengine / godotengine/godot

Callable::is_null does not check custom callable name.

Open
#95,231 0 comments 0 reactions 0 assignees View on GitHub
discussion topic:core
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.2.2

### System information

Windows 11

### Issue description

I think there is an undesired behaviour in `Callable::is_null` method I found while designing lambda callables for `godot-kotlin`:
```cpp
_FORCE_INLINE_ bool is_null() const {
return method == StringName() && object == 0;
}
```

This method checks the `method` property, which is empty `StringName` for `CustomCallable`, which force to create a middleman to not have `object == 0`. (I think that's why C# has a middleman for their delegate callables)
I think changing the use of `method` property by a call to `Callable::get_method` would get rid of those middleman:

```cpp
StringName Callable::get_method() const {
if (is_custom()) {
return get_custom()->get_method();
}
return method;
}
```

### Steps to reproduce

None to provide.

### Minimal reproduction project (MRP)

None to provide.

Contributor guide

Open the contributing guide

Research direction

Start by locating the implementations of Callable::is_null and Callable::get_method, then inspect how CustomCallable stores and exposes its method name. Confirm the behavior with the existing callable tests, if present; done means a custom callable with a method name is not treated as null without requiring a middleman.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.