From d31002cfbee5f33c335c329d24be8d82fb04bcc5 Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Mon, 10 Apr 2023 09:54:53 +0300 Subject: GDScript: Add missing member type check when resolving `extends` (cherry picked from commit 66279b98b6c3418232003cc8d6c2e52af7a62ac4) --- .../scripts/analyzer/errors/extend_non_class_constant_1.gd | 9 +++++++++ .../scripts/analyzer/errors/extend_non_class_constant_1.out | 2 ++ .../scripts/analyzer/errors/extend_non_class_constant_2.gd | 12 ++++++++++++ .../scripts/analyzer/errors/extend_non_class_constant_2.out | 2 ++ .../tests/scripts/analyzer/errors/extend_variable.gd | 9 +++++++++ .../tests/scripts/analyzer/errors/extend_variable.out | 2 ++ 6 files changed, 36 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out (limited to 'modules/gdscript/tests/scripts') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd new file mode 100644 index 0000000000..72af099158 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.gd @@ -0,0 +1,9 @@ +# GH-75870 + +const A = 1 + +class B extends A: + pass + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out new file mode 100644 index 0000000000..65d629a35b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_1.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Constant "A" is not a preloaded script or class. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd new file mode 100644 index 0000000000..fe334f8cb7 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.gd @@ -0,0 +1,12 @@ +# GH-75870 + +class A: + const X = 1 + +const Y = A.X # A.X is now resolved. + +class B extends A.X: + pass + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out new file mode 100644 index 0000000000..951cfb1ea4 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_non_class_constant_2.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Identifier "X" is not a preloaded script or class. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd b/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd new file mode 100644 index 0000000000..6574d4cf31 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.gd @@ -0,0 +1,9 @@ +# GH-75870 + +var A = 1 + +class B extends A: + pass + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out b/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out new file mode 100644 index 0000000000..7b39af6979 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/extend_variable.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Cannot use variable "A" in extends chain. -- cgit v1.2.3