-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate errors for getters that return no value #79363
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This adds validation only for inline getters (PROP_INLINE
). Perhaps we should do this for separated getters (PROP_SETGET
) as well?
modules/gdscript/tests/scripts/analyzer/errors/getter_no_return.gd
Outdated
Show resolved
Hide resolved
58302ee
to
9e1f24d
Compare
9e1f24d
to
aee2a72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, except for a minor note.
Also I noticed that empty return
doesn't raise an error/warning:
var property:
get:
return
But this is beyond the scope of this PR, as it happens here too:
func my_func() -> Variant:
return
In my opinion empty return
should only be used with void
functions or if no return type is specified. In a type is specified or it is getter, return
must be non-empty (explicit return null
).
aee2a72
to
bd17525
Compare
Discussed (a lot) during the GDScript meeting. Currently, we would wait a bit before merging this PR to make sure that a future PR (@dalexeev ?) in that vein (the following citation) would still be compatible with/not make obsolete this PR.
There's no rush to merge this PR yet, but thank you @garychia for that PR, we will follow with something soon. |
Replaced #63541
Fixes #63393
Getters now must return a value.