godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.08k stars 69 forks source link

Show error when attempting to compare the type of statically typed variable #8805

Closed diklor closed 4 days ago

diklor commented 6 months ago

Describe the project you are working on

All

Describe the problem or limitation you are having in your project

There is no small feature for typification

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Show a warning / error when checking the type of a variable whose type is already defined via typeof() (In any case, it can be changed in the settings)

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

func parameter(string: String) -> void:
   if typeof(string) != TYPE_STRING:      return
   #ERROR: Attempt to compare the type of a static variable

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, but it's just convenient for statically typed code

Is there a reason why this should be core and not an add-on in the asset library?

GDScript

AThousandShips commented 6 months ago

This should be a warning not an error (only warnings can be controlled in the settings) and should default to warning, at most