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
The expected result would be that it prints "hi" to the console; however, this instead pushes the following error:
Attempt to call function 'null::print_hi (Callable)' on a null instance.
Calling print_hi() from within other() works fine, but the self object seems to be cleaned up after the callable is returned, resulting in calling it on a null instance. I believe the callable should capture its self object when bound like this.
Steps to reproduce
Create a new function.
Create new object inside of that function and return a bound callable method from it.
Call the function from some other code, and call .call() or .callv() on the returned callable.
Observe the editor error, which says that the initial object is null.
I guess the reason is that in Test.new().print_hi, Test.new() returns a RefCounted object which you don't have a reference of that making the object is freed automatically. So it became null.
If you define class Test extends Object, then the error will disappear but it may cause memory leaking if you don't hold a reference of this object and free it manually when you don't need it.
Tested versions
System information
Godot v4.3.stable (77dcf97) - NixOS #1-NixOS SMP PREEMPT_DYNAMIC Wed Sep 18 17:24:10 UTC 2024 - X11 - GLES3 (Compatibility)
Issue description
Consider the following code:
The expected result would be that it prints "hi" to the console; however, this instead pushes the following error:
Calling
print_hi()
from withinother()
works fine, but the self object seems to be cleaned up after the callable is returned, resulting in calling it on a null instance. I believe the callable should capture its self object when bound like this.Steps to reproduce
.call()
or.callv()
on the returned callable.Minimal reproduction project (MRP)
test.zip
The text was updated successfully, but these errors were encountered: