From 015cc389129cb6a78a45c9d8ee2eadd970e9f6eb Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 24 Jun 2025 18:03:52 +0200 Subject: [PATCH] Mark GDScript and shader warnings for translation --- doc/classes/ProjectSettings.xml | 9 --- modules/gdscript/gdscript.cpp | 6 ++ modules/gdscript/gdscript_warning.cpp | 88 +++++++++++++-------------- servers/rendering/shader_warnings.cpp | 20 +++--- 4 files changed, 60 insertions(+), 63 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 6c3e78ace0f..0e0cfee3189 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -527,9 +527,6 @@ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when an identifier that will be shadowed below in the block is used. - - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a constant is used as a function. - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when deprecated keywords are used. [b]Note:[/b] There are currently no deprecated keywords, so this warning is never produced. @@ -546,9 +543,6 @@ If [code]true[/code], scripts in the [code]res://addons[/code] folder will not generate warnings. - - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when using a function as if it is a property. - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when [method Node.get_node] (or the shorthand [code]$[/code]) is used as default value of a class variable without the [code]@onready[/code] annotation. @@ -583,9 +577,6 @@ When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when the [code]@onready[/code] annotation is used together with the [code]@export[/code] annotation, since it may not behave as expected. - - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when using a property as if it is a function. - When set to [code]warn[/code] or [code]error[/code], produces a warning or an error respectively when a function that is not a coroutine is called with await. diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 5da5c9e458e..a0d8913b631 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2964,6 +2964,12 @@ GDScriptLanguage::GDScriptLanguage() { String path = GDScriptWarning::get_settings_path_from_code(code); GLOBAL_DEF(GDScriptWarning::get_property_info(code), default_enabled); } + +#ifndef DISABLE_DEPRECATED + ProjectSettings::get_singleton()->set_as_internal("debug/gdscript/warnings/property_used_as_function", true); + ProjectSettings::get_singleton()->set_as_internal("debug/gdscript/warnings/constant_used_as_function", true); + ProjectSettings::get_singleton()->set_as_internal("debug/gdscript/warnings/function_used_as_property", true); +#endif #endif // DEBUG_ENABLED } diff --git a/modules/gdscript/gdscript_warning.cpp b/modules/gdscript/gdscript_warning.cpp index a4ed51d4242..7ba47f8786f 100644 --- a/modules/gdscript/gdscript_warning.cpp +++ b/modules/gdscript/gdscript_warning.cpp @@ -194,50 +194,50 @@ String GDScriptWarning::get_name_from_code(Code p_code) { ERR_FAIL_COND_V(p_code < 0 || p_code >= WARNING_MAX, String()); static const char *names[] = { - "UNASSIGNED_VARIABLE", - "UNASSIGNED_VARIABLE_OP_ASSIGN", - "UNUSED_VARIABLE", - "UNUSED_LOCAL_CONSTANT", - "UNUSED_PRIVATE_CLASS_VARIABLE", - "UNUSED_PARAMETER", - "UNUSED_SIGNAL", - "SHADOWED_VARIABLE", - "SHADOWED_VARIABLE_BASE_CLASS", - "SHADOWED_GLOBAL_IDENTIFIER", - "UNREACHABLE_CODE", - "UNREACHABLE_PATTERN", - "STANDALONE_EXPRESSION", - "STANDALONE_TERNARY", - "INCOMPATIBLE_TERNARY", - "UNTYPED_DECLARATION", - "INFERRED_DECLARATION", - "UNSAFE_PROPERTY_ACCESS", - "UNSAFE_METHOD_ACCESS", - "UNSAFE_CAST", - "UNSAFE_CALL_ARGUMENT", - "UNSAFE_VOID_RETURN", - "RETURN_VALUE_DISCARDED", - "STATIC_CALLED_ON_INSTANCE", - "MISSING_TOOL", - "REDUNDANT_STATIC_UNLOAD", - "REDUNDANT_AWAIT", - "ASSERT_ALWAYS_TRUE", - "ASSERT_ALWAYS_FALSE", - "INTEGER_DIVISION", - "NARROWING_CONVERSION", - "INT_AS_ENUM_WITHOUT_CAST", - "INT_AS_ENUM_WITHOUT_MATCH", - "ENUM_VARIABLE_WITHOUT_DEFAULT", - "EMPTY_FILE", - "DEPRECATED_KEYWORD", - "CONFUSABLE_IDENTIFIER", - "CONFUSABLE_LOCAL_DECLARATION", - "CONFUSABLE_LOCAL_USAGE", - "CONFUSABLE_CAPTURE_REASSIGNMENT", - "INFERENCE_ON_VARIANT", - "NATIVE_METHOD_OVERRIDE", - "GET_NODE_DEFAULT_WITHOUT_ONREADY", - "ONREADY_WITH_EXPORT", + PNAME("UNASSIGNED_VARIABLE"), + PNAME("UNASSIGNED_VARIABLE_OP_ASSIGN"), + PNAME("UNUSED_VARIABLE"), + PNAME("UNUSED_LOCAL_CONSTANT"), + PNAME("UNUSED_PRIVATE_CLASS_VARIABLE"), + PNAME("UNUSED_PARAMETER"), + PNAME("UNUSED_SIGNAL"), + PNAME("SHADOWED_VARIABLE"), + PNAME("SHADOWED_VARIABLE_BASE_CLASS"), + PNAME("SHADOWED_GLOBAL_IDENTIFIER"), + PNAME("UNREACHABLE_CODE"), + PNAME("UNREACHABLE_PATTERN"), + PNAME("STANDALONE_EXPRESSION"), + PNAME("STANDALONE_TERNARY"), + PNAME("INCOMPATIBLE_TERNARY"), + PNAME("UNTYPED_DECLARATION"), + PNAME("INFERRED_DECLARATION"), + PNAME("UNSAFE_PROPERTY_ACCESS"), + PNAME("UNSAFE_METHOD_ACCESS"), + PNAME("UNSAFE_CAST"), + PNAME("UNSAFE_CALL_ARGUMENT"), + PNAME("UNSAFE_VOID_RETURN"), + PNAME("RETURN_VALUE_DISCARDED"), + PNAME("STATIC_CALLED_ON_INSTANCE"), + PNAME("MISSING_TOOL"), + PNAME("REDUNDANT_STATIC_UNLOAD"), + PNAME("REDUNDANT_AWAIT"), + PNAME("ASSERT_ALWAYS_TRUE"), + PNAME("ASSERT_ALWAYS_FALSE"), + PNAME("INTEGER_DIVISION"), + PNAME("NARROWING_CONVERSION"), + PNAME("INT_AS_ENUM_WITHOUT_CAST"), + PNAME("INT_AS_ENUM_WITHOUT_MATCH"), + PNAME("ENUM_VARIABLE_WITHOUT_DEFAULT"), + PNAME("EMPTY_FILE"), + PNAME("DEPRECATED_KEYWORD"), + PNAME("CONFUSABLE_IDENTIFIER"), + PNAME("CONFUSABLE_LOCAL_DECLARATION"), + PNAME("CONFUSABLE_LOCAL_USAGE"), + PNAME("CONFUSABLE_CAPTURE_REASSIGNMENT"), + PNAME("INFERENCE_ON_VARIANT"), + PNAME("NATIVE_METHOD_OVERRIDE"), + PNAME("GET_NODE_DEFAULT_WITHOUT_ONREADY"), + PNAME("ONREADY_WITH_EXPORT"), #ifndef DISABLE_DEPRECATED "PROPERTY_USED_AS_FUNCTION", "CONSTANT_USED_AS_FUNCTION", diff --git a/servers/rendering/shader_warnings.cpp b/servers/rendering/shader_warnings.cpp index a325000d77d..d63b078e668 100644 --- a/servers/rendering/shader_warnings.cpp +++ b/servers/rendering/shader_warnings.cpp @@ -85,16 +85,16 @@ String ShaderWarning::get_name_from_code(Code p_code) { ERR_FAIL_INDEX_V(p_code, WARNING_MAX, String()); static const char *names[] = { - "FLOAT_COMPARISON", - "UNUSED_CONSTANT", - "UNUSED_FUNCTION", - "UNUSED_STRUCT", - "UNUSED_UNIFORM", - "UNUSED_VARYING", - "UNUSED_LOCAL_VARIABLE", - "FORMATTING_ERROR", - "DEVICE_LIMIT_EXCEEDED", - "MAGIC_POSITION_WRITE", + PNAME("FLOAT_COMPARISON"), + PNAME("UNUSED_CONSTANT"), + PNAME("UNUSED_FUNCTION"), + PNAME("UNUSED_STRUCT"), + PNAME("UNUSED_UNIFORM"), + PNAME("UNUSED_VARYING"), + PNAME("UNUSED_LOCAL_VARIABLE"), + PNAME("FORMATTING_ERROR"), + PNAME("DEVICE_LIMIT_EXCEEDED"), + PNAME("MAGIC_POSITION_WRITE"), }; static_assert(std::size(names) == WARNING_MAX, "Amount of warning types don't match the amount of warning names.");