warning_system.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. As shown in the image above, you must enable **Advanced Settings** in order to see the GDScript section.
  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 3 warnings:
  17. .. figure:: img/typed_gdscript_warning_example.png
  18. :alt: Warning system example
  19. Warning system example
  20. To ignore specific warnings in one file, insert a special comment of the
  21. form ``# warning-ignore:warning-id``, or click on the ignore link to the
  22. right of the warning's description. Godot will add a comment above the
  23. corresponding line and the code won't trigger the corresponding warning
  24. anymore:
  25. .. figure:: img/typed_gdscript_warning_system_ignore.png
  26. :alt: Warning system ignore example
  27. Warning system ignore example
  28. You can also choose to ignore not just one but all warnings of a certain
  29. type in this file with ``# warning-ignore-all:warning-id``. To ignore all
  30. warnings of all types in a file add the comment ``# warnings-disable`` to it.
  31. Warnings won't prevent the game from running, but you can turn them into
  32. errors if you'd like. This way your game won't compile unless you fix
  33. all warnings. Head to the ``GDScript`` section of the Project Settings to
  34. turn on this option. Here's the same file as the previous example with
  35. warnings as errors turned on:
  36. .. figure:: img/typed_gdscript_warning_system_errors.png
  37. :alt: Warnings as errors
  38. Warnings as errors