This code snippet can run without any error or warning. It seems that the signal object does not check the number of parameters of its connected functions. So, the argument list is redundant???
Is the argument list of a signal meaningless?
- Edited
For those, who wonder: Static typing does not add any value beyond documentation, as well. The following example compiles without any error.
extends Node
signal test_signal(a: int)
func _ready():
test_signal.connect(func (a: String): print(a)) # connect a non-matching Callable
test_signal.emit("abc") # pass non-matching argument (wrt. test_signal)
test_signal.emit(false) # pass non-matching argument (wrt. Callable and test_signal)
The last line causes a runtime error, because the arguments do not match those of the Callable, though.
The argument list of signal is only useful for documentation purposes. See also https://github.com/godotengine/godot/issues/54333#issuecomment-1502908418.
kuligs2 Yes, that's true. However, if you make a mistake when declaring a signal, it can be quite confusing when you revisit the code later. Something apparently not correct, but it works right...
And, consider the following scenario:
extends Control
signal test_signal3(a, b, c, d, e, f, g)
func _ready():
# suppose this is located in another script
test_signal3.connect(func(a, b): print("test_signal3:", a, b))
# you use this signal following the signal signature
test_signal3.connect(func(a, b, c, d, e, f, g): print("test_signal3:", a, b, c, d, e, f, g))
test_signal3.emit(1,2,3,4,5,6,7)
# then you will get the right output with a very confusing error: Error calling from signal 'test_signal3' to callable: 'GDScript::<anonymous lambda>': Method expected 2 arguments, but called with 7.
So I think the number of parameters should at least be checked for correctness. It seems like this isn't such an easy thing to do..
From reading the github issues relating to this, my conclusion is that fixing this requires someone to implement it and submit a Pull Request.