signal receivers should emit a warning when they ignore invalidly typed signal arguments #10372
TARDIInsanity
started this conversation in
Engine Core
Replies: 1 comment
-
See also: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There's a very specific unintuitive feature with signals which only an error at runtime of the form
E 0:00:09:0619 menu.gd:41 @ on_delete(): Error calling from signal 'deleted' to callable: 'Panel(space.gd)::_on_menu_delete': Cannot convert argument 1 from Array to Array.
; this error is non-breaking and simply results in the program ignoring the signal entirely. No warning or error is available outside of runtime.here's my code sample:
and the listener:
_on_menu_delete
will never receive the signal, in my case resulting in either a memory leak (if the delete is handled in the listener) or a data discrepancy (if the delete is handled by the deleter) in my vertex tracking system. By adding a static type to 'copy' that matches the expected argument type, however, it suddenly receives the signal, showing that this is the only issue. Even if this specific use case is some kind of bad code pattern, programmers are sure to run into this issue especially with array typing, as well as refactoring, and in other common scenarios. Is this standard and expected, or is this a bug? This should raise a warning in the editor, and not a non-breaking console runtime error on signal transmission, much like with integer division and other basic warnings about behaviors that may be desired sometimes but can also be footguns. I open this issue as a discussion because, based on the reproducibility of this behavior, it's very likely that this sort of fault-tolerance is intentional, even though it may lead to bad design patterns such as type-switching where several listeners each look for a different type signature in the signal and only one of them receives it based on the type provided.Of note: the signal definition, currently, supports typed arguments. The error changes, but remains a runtime-only non-breaking error, in the form of
E 0:00:04:0052 vert_menu.gd:41 @ on_delete_press(): Error calling from signal 'deleted' to callable: 'Panel(space.gd)::on_vertices_deleted': Cannot convert argument 1 from Array to Array.
; the program will simply ignore the call and proceed.Beta Was this translation helpful? Give feedback.
All reactions