godot icon indicating copy to clipboard operation
godot copied to clipboard

[3.x] Fix Signal parameters' type will now be correctly displayed in the node signal preview box.

Open Life4gal opened this issue 3 years ago • 4 comments

Version of Godot based on: v3.5.1.rc.custom_build [26a28d6bb]

Fixes #65809

Signal parameters' type will now be correctly displayed in the node signal preview box.

This is a fix for the 3.x version, if the 3.x version does not require the ability to specify the parameter type of the signal, please close this PR

See also #65812

signal_arg_type_3 x_1 signal_arg_type_3 x_2

Life4gal avatar Sep 17 '22 01:09 Life4gal

I'm sorry about force-pushed, but due to some previous oversights (forgetting git config), some information that did not belong to me was leaked. So I used rebase and push -f to get this PR(and commit) updated. :)

Life4gal avatar Sep 17 '22 01:09 Life4gal

As far as I know, 3.x doesn't support type information for user defined signals.

~~As evident from your screenshot, it even produces false negatives (as the "invalid" signal is not actually invalid).~~ Edit: Ah, this is your addition. Still, the rest of the point stands.

So we do not advise using types with signal definitions, even if you do use the type system otherwise. This makes the usefulness of this change in 3.x very limited.

YuriSizov avatar Sep 17 '22 13:09 YuriSizov

As far as I know, 3.x doesn't support type information for user defined signals.

~As evident from your screenshot, it even produces false negatives (as the "invalid" signal is not actually invalid).~ Edit: Ah, this is your addition. Still, the rest of the point stands.

So we do not advise using types with signal definitions, even if you do use the type system otherwise. This makes the usefulness of this change in 3.x very limited.

Perhaps for most users, the parameter type of signal is meaningless most of the time. Unless their primary way of development is to use VisualScript.

If GDScript supports signal parameter types, it will greatly help VisualScript development. why_signal_arg_type_needed_1 why_signal_arg_type_needed_2

But 4.x removes VisualScript support, so maybe this change only makes sense for 3.x for now?

Life4gal avatar Sep 19 '22 01:09 Life4gal

Perhaps for most users, the parameter type of signal is meaningless most of the time.

It's not meaningless to people using the type system, but it's non-functional so far, and there were no plans to make it functional in Godot 3.x. And since it's not functional, there are no plans to make it even as an optional syntax to avoid confusing users as if type safety is guaranteed. In 4.x we want it to be functional, but it will happen with a later version, not Godot 4.0.

No idea how useful it is for VisualScript.

YuriSizov avatar Sep 19 '22 13:09 YuriSizov

No idea how useful it is for VisualScript.

Indeed, for GDSccript, this optional syntax for setting types has no actual type guarantees, nor does it constrain the user not to pass in incorrect variables.

But if a signal's parameter is typed in VisualScript, then it is guaranteed to use the parameter in the correct way.

Life4gal avatar Sep 20 '22 01:09 Life4gal

signal_arg_type_validate_1 signal_arg_type_validate_2 😄 😄 😄 I did it!

Life4gal avatar Sep 21 '22 10:09 Life4gal

Non-built-in types are now supported too!😄 😄 😄 signal_arg_type_validate_3

For GDScript it works perfectly. signal_arg_type_validate_4

The only pity is that VisualScript only supports built-in types, so only the Object type can be used. 😭 😭 😭 signal_arg_type_validate_5

Life4gal avatar Sep 22 '22 05:09 Life4gal

It's not meaningless to people using the type system, but it's non-functional so far, and there were no plans to make it functional in Godot 3.x. And since it's not functional, there are no plans to make it even as an optional syntax to avoid confusing users as if type safety is guaranteed. In 4.x we want it to be functional, but it will happen with a later version, not Godot 4.0.

I think it's functional enough now! 😃

Life4gal avatar Sep 22 '22 05:09 Life4gal