Jelajahi Sumber

Add note in GDScript reference about inference with Variant (#6934)

George Marques 2 tahun lalu
induk
melakukan
4d86f91ff7
1 mengubah file dengan 10 tambahan dan 0 penghapusan
  1. 10 0
      tutorials/scripting/gdscript/gdscript_basics.rst

+ 10 - 0
tutorials/scripting/gdscript/gdscript_basics.rst

@@ -760,6 +760,16 @@ Valid types are:
 - Script classes declared with the ``class_name`` keyword.
 - Autoloads registered as singletons.
 
+.. note::
+
+    While ``Variant`` is a valid type specification, it's not an actual type. It
+    only means there's no set type and is equivalent to not having a static type
+    at all. Therefore, inference is not allowed by default for ``Variant``,
+    since it's likely a mistake.
+
+    You can turn off this check, or make it only a warning, by changing it in
+    the project settings. See :ref:`doc_gdscript_warning_system` for details.
+
 Casting
 ^^^^^^^