warning_system.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. .. _doc_gdscript_warning_system:
  2. GDScript warning system
  3. =======================
  4. The GDScript warning system complements :ref:`static typing <doc_gdscript_static_typing>`
  5. (but it can work without static typing too). It's here to help you avoid
  6. mistakes that are hard to spot during development, and that may lead
  7. to runtime errors.
  8. You can configure warnings in the Project Settings under the section
  9. called **GDScript**:
  10. .. image:: img/typed_gdscript_warning_system_settings.webp
  11. .. note::
  12. You must enable **Advanced Settings** in order to see the
  13. GDScript section in the sidebar. You can also search for "GDScript" when
  14. Advanced Settings is off.
  15. You can find a list of warnings for the active GDScript file in the
  16. script editor's status bar. The example below has 2 warnings:
  17. .. image:: img/typed_gdscript_warning_example.webp
  18. To ignore specific warnings in one file, insert an annotation of the
  19. form ``@warning_ignore("warning-id")``, or click on the ignore link to the
  20. left of the warning's description. Godot will add an annotation above the
  21. corresponding line and the code won't trigger the corresponding warning
  22. anymore:
  23. .. image:: img/typed_gdscript_warning_system_ignore.webp
  24. Warnings won't prevent the game from running, but you can turn them into
  25. errors if you'd like. This way your game won't compile unless you fix
  26. all warnings. Head to the ``GDScript`` section of the Project Settings to
  27. turn on this option to the warning that you want. Here's the same file as
  28. the previous example with the warning ``unused_variable`` as an error turned on:
  29. .. image:: img/typed_gdscript_warning_system_errors.webp