From 7b7952ae7112e324663ec28d593ea030ddf49bed Mon Sep 17 00:00:00 2001 From: Lexyth Date: Wed, 19 Mar 2025 00:37:10 +0100 Subject: [PATCH 1/4] Clarify type-safety of as Changed the statement about the as keyword's type-safety to clarify that it is less type-safe than type hints. --- tutorials/scripting/gdscript/gdscript_styleguide.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tutorials/scripting/gdscript/gdscript_styleguide.rst b/tutorials/scripting/gdscript/gdscript_styleguide.rst index 6230736eab4..1fe696b944e 100644 --- a/tutorials/scripting/gdscript/gdscript_styleguide.rst +++ b/tutorials/scripting/gdscript/gdscript_styleguide.rst @@ -1050,7 +1050,10 @@ that type will be used to infer the type of the var. @onready var health_bar := get_node("UI/LifeBar") as ProgressBar # health_bar will be typed as ProgressBar -This option is also considered more :ref:`type-safe` than the first. + +.. note:: + + This option is considered less :ref:`type-safe` than type hints, as it silently casts the variable to null in case of a type mismatch at runtime, without an error/warning **Bad**: From 58c9fdb6b5e5dd3ded7963a7be2681e72e642181 Mon Sep 17 00:00:00 2001 From: Lexyth Date: Sun, 23 Mar 2025 10:28:47 +0100 Subject: [PATCH 2/4] Clarify null-safety vs type-safety Changed the statement about the "as" keyword to clarify that it affects null-safety, not type-safety. --- tutorials/scripting/gdscript/gdscript_styleguide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/scripting/gdscript/gdscript_styleguide.rst b/tutorials/scripting/gdscript/gdscript_styleguide.rst index 1fe696b944e..30e5a51e3a5 100644 --- a/tutorials/scripting/gdscript/gdscript_styleguide.rst +++ b/tutorials/scripting/gdscript/gdscript_styleguide.rst @@ -1053,7 +1053,7 @@ that type will be used to infer the type of the var. .. note:: - This option is considered less :ref:`type-safe` than type hints, as it silently casts the variable to null in case of a type mismatch at runtime, without an error/warning + This option is considered more :ref:`type-safe` than type hints, but also less null-safe as it silently casts the variable to null in case of a type mismatch at runtime, without an error/warning. **Bad**: From 8609443a5be3f1d33e33d6a3d8a1d76c700de318 Mon Sep 17 00:00:00 2001 From: Lexyth Date: Sun, 23 Mar 2025 11:15:29 +0100 Subject: [PATCH 3/4] Update format Used code-block format for "null" keyword. Co-authored-by: Danil Alexeev --- tutorials/scripting/gdscript/gdscript_styleguide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/scripting/gdscript/gdscript_styleguide.rst b/tutorials/scripting/gdscript/gdscript_styleguide.rst index 30e5a51e3a5..afa0a33756c 100644 --- a/tutorials/scripting/gdscript/gdscript_styleguide.rst +++ b/tutorials/scripting/gdscript/gdscript_styleguide.rst @@ -1053,7 +1053,7 @@ that type will be used to infer the type of the var. .. note:: - This option is considered more :ref:`type-safe` than type hints, but also less null-safe as it silently casts the variable to null in case of a type mismatch at runtime, without an error/warning. + This option is considered more :ref:`type-safe` than type hints, but also less null-safe as it silently casts the variable to ``null`` in case of a type mismatch at runtime, without an error/warning. **Bad**: From 571a85decf73dc604651780aa35ed3bfb9e174eb Mon Sep 17 00:00:00 2001 From: Lexyth Date: Sun, 23 Mar 2025 15:21:15 +0100 Subject: [PATCH 4/4] Update line length Reduced the line length to make it more readable. Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> --- tutorials/scripting/gdscript/gdscript_styleguide.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tutorials/scripting/gdscript/gdscript_styleguide.rst b/tutorials/scripting/gdscript/gdscript_styleguide.rst index afa0a33756c..9e0c09dbebf 100644 --- a/tutorials/scripting/gdscript/gdscript_styleguide.rst +++ b/tutorials/scripting/gdscript/gdscript_styleguide.rst @@ -1053,7 +1053,9 @@ that type will be used to infer the type of the var. .. note:: - This option is considered more :ref:`type-safe` than type hints, but also less null-safe as it silently casts the variable to ``null`` in case of a type mismatch at runtime, without an error/warning. + This option is considered more :ref:`type-safe` than type hints, + but also less null-safe as it silently casts the variable to ``null`` in case of a type mismatch at runtime, + without an error/warning. **Bad**: