From 5d164df4e15a4e76feaa187053c05127a98225e1 Mon Sep 17 00:00:00 2001 From: "ocean (they/them)" Date: Sun, 2 Apr 2023 18:10:32 -0400 Subject: [PATCH] Make type not found errors more informative. This PR removes a check for whether a datatype is a meta type when generating a datatype's to_string() result. This means that error messages that fail to find the type will now print their class names, which is much more useful when trying to identify errors. --- modules/gdscript/gdscript_parser.cpp | 3 --- .../scripts/analyzer/errors/prints_base_type_not_found.gd | 6 ++++++ .../scripts/analyzer/errors/prints_base_type_not_found.out | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index e2a37ab6e90..fe046ccdd1f 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -4121,9 +4121,6 @@ String GDScriptParser::DataType::to_string() const { } return native_type.operator String(); case CLASS: - if (is_meta_type) { - return GDScript::get_class_static(); - } if (class_type->identifier != nullptr) { return class_type->identifier->name.operator String(); } diff --git a/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd new file mode 100644 index 00000000000..e56ae7b11d3 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.gd @@ -0,0 +1,6 @@ +class InnerClass: + pass + +func test(): + var x : InnerClass.DoesNotExist + print("FAIL") diff --git a/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out new file mode 100644 index 00000000000..29c75ae3c09 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/prints_base_type_not_found.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Could not find type "DoesNotExist" under base "InnerClass".