godotengine / godotengine/godot
Functions passed as arguments cannot be called with `()` operator, but error message is insufficiently clear
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
v4.3.stable.official [77dcf97d8]
### System information
Windows 11
### Issue description
``` gdscript
# The following does not work. Error: Function "call_me()" not found in base self.
var fn1 = func(call_me): call_me()
# No error. It refers to the local variable "call_me" instead of self. That's correct.
var fn2 = func(call_me): print(call_me)
# Workaround: Use call or wrap it in Callable. Not very comfortable.
var fn3 = func(call_me): call_me.call()
var fn4 = func(call_me): Callable(call_me).call()
```
I expected that the local variable (parameter) "call_me" is used. But it refers to self? Use local variable first, when fallback to class self and global. It seems to be a bug or something that can be changed.
### Steps to reproduce
Code is worth a thousand words. Please see above.
### Minimal reproduction project (MRP)
Please paste the code block above in your Godot editor.
Contributor guide
Research direction
Run the supplied GDScript reproduction in the Godot editor first and confirm the behavior on the reported version. Then trace the language name-resolution and function-call handling from this example; done means the intended parameter behavior or a sufficiently clear diagnostic is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100