warning_system.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. .. figure:: img/typed_gdscript_warning_system_settings.webp
  11. :alt: Warning system project settings
  12. Warning system project settings
  13. .. note::
  14. You must enable **Advanced Settings** in order to see the
  15. GDScript section in the sidebar. You can also search for "GDScript" when
  16. Advanced Settings is off.
  17. You can find a list of warnings for the active GDScript file in the
  18. script editor's status bar. The example below has 3 warnings:
  19. .. figure:: img/typed_gdscript_warning_example.png
  20. :alt: Warning system example
  21. Warning system example
  22. To ignore specific warnings in one file, insert a special comment of the
  23. form ``# warning-ignore:warning-id``, or click on the ignore link to the
  24. right of the warning's description. Godot will add a comment above the
  25. corresponding line and the code won't trigger the corresponding warning
  26. anymore:
  27. .. figure:: img/typed_gdscript_warning_system_ignore.png
  28. :alt: Warning system ignore example
  29. Warning system ignore example
  30. You can also choose to ignore not just one but all warnings of a certain
  31. type in this file with ``# warning-ignore-all:warning-id``. To ignore all
  32. warnings of all types in a file add the comment ``# warnings-disable`` to it.
  33. Warnings won't prevent the game from running, but you can turn them into
  34. errors if you'd like. This way your game won't compile unless you fix
  35. all warnings. Head to the ``GDScript`` section of the Project Settings to
  36. turn on this option. Here's the same file as the previous example with
  37. warnings as errors turned on:
  38. .. figure:: img/typed_gdscript_warning_system_errors.png
  39. :alt: Warnings as errors
  40. Warnings as errors