-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Use different syntax and semantics for GDScript warning exemptions #753
Comments
Might be already on the roadmap, not sure: godotengine/godot#20318.
Some marginally related proposal to help with string case conversions: #719. |
While we're at it, we should probably remove the "catch-all" Instead, users should always specify the warning they're ignoring, which makes it safer and more specific (you can read the code and know the warning that was ignored immediately). |
@Calinou Yeah, that sounds like a really good idea to me. In that case though, we'll also need to be able to specify multiple ignores for the following line, eg. @warning_ignore unused_variable integer_division
var i: int = 3 / 4 This also throws up the question of whether to completely ditch |
Well if a developer starts to ignore warnings like that it might signify that the warning system may actually be not so useful (for now), and it's only natural because you can't really come up with a system which could satisfy most users. For instance, if I were to treat all warnings as errors, some warnings like func _ready() -> void:
set_pause_mode(PAUSE_MODE_PROCESS)
# warning-ignore:return_value_discarded
get_tree().connect("network_peer_connected",self,"_network_peer_connected")
# warning-ignore:return_value_discarded
get_tree().connect("network_peer_disconnected",self,"_network_peer_disconnected")
# warning-ignore:return_value_discarded
get_tree().connect("connected_to_server", self, "_connected_ok")
# warning-ignore:return_value_discarded
get_tree().connect("connection_failed", self, "_connection_failed")
# warning-ignore:return_value_discarded
get_tree().connect("server_disconnected",self,"_server_disconnected") Quite difficult to parse (visually), and that's one of the most used functions in Godot IMO. To compare, there's a special implicit discard syntax which I personally like better than the above (the underscore func _ready():
var _err = OK
_err = get_tree().connect("network_peer_connected",self,"_network_peer_connected")
_err = get_tree().connect("network_peer_disconnected",self,"_network_peer_disconnected")
_err = get_tree().connect("connected_to_server", self, "_connected_ok")
_err = get_tree().connect("connection_failed", self, "_connection_failed")
_err = get_tree().connect("server_disconnected",self,"_server_disconnected") That's just to convey an idea. |
@Xrayez Making |
A more Haskell-esque Edit: huh, can't seem to find them. Sorry if I dreamt that! |
@snoopdouglas This could be done once This could also be done by adding a |
Hmm, I'd personally prefer |
I don't get assigning variables just to prevent a warning. I always disable the "Discarded return value" warning and I think it should be disabled by default, as it's almost never actually a problem. |
Absolutely. But - in my opinion - that's a lesser problem than my program ending up in an undefined state because I forgot to act upon a return value somewhere, so it's good that a warning exists for this, regardless of its default enablement. Keeping this on-topic though, those defaults aren't what I intended us to be discussing here. |
I do intend to move those to annotations (#828). Only difference is that parentheses and commas are required, like a function call. It will also be possible to implement completion for it.
It's the opposite IMO. |
This should've been closed, |
Describe the project you are working on:
A space shooter.
Describe the problem or limitation you are having in your project:
I'm an old GCC blowhard, and so want to treat warnings as errors. I've figured out how to use
#warning-ignore:
, but it hasn't been easy.Describe the feature / enhancement and how it helps to overcome the problem or limitation:
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
@
is a common character to use for decorators, and I think it'd apply nicely here.Additionally, as it stands, the first half of the expression is kebab-cased while the second is snake_cased. I understand how this might've come about, but still think it should change. There isn't anything else in GDScript, to my knowledge, that uses kebab-casing.
Here's an example:
Note the change in semantics for the last example: as it stands, multiple
#warning-ignore
lines need to precede a line which breaks the rules multiple times.And to replace
#warnings-disable
:# disable all warnings for this entire file @warnings_disable
However: the pluralisation
warnings
here annoys me a bit, as does the similarity in semantics between the wordsignore
anddisable
.@warning_ignore_all
has no plural, but it is plural in nature. Maybe something for discussion.If this enhancement will not be used often, can it be worked around with a few lines of script?:
No.
Is there a reason why this should be core and not an add-on in the asset library?:
Addons can't change GDScript semantics (to my knowledge), and IMHO they shouldn't.
CC: godotengine/godot-docs#3447
The text was updated successfully, but these errors were encountered: