From 68a567bd1389a2cb410fc002632ccd5b5fb59f5c Mon Sep 17 00:00:00 2001 From: Danil Alexeev Date: Thu, 24 Aug 2023 19:01:31 +0300 Subject: GDScript: Allow use local constants as types --- .../analyzer/errors/local_const_as_type_use_before_declared.gd | 5 +++++ .../analyzer/errors/local_const_as_type_use_before_declared.out | 2 ++ .../scripts/analyzer/errors/local_const_as_type_use_not_const.gd | 5 +++++ .../scripts/analyzer/errors/local_const_as_type_use_not_const.out | 2 ++ .../scripts/analyzer/errors/local_const_as_type_use_not_type.gd | 5 +++++ .../scripts/analyzer/errors/local_const_as_type_use_not_type.out | 2 ++ 6 files changed, 21 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out (limited to 'modules/gdscript/tests/scripts/analyzer/errors') diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd new file mode 100644 index 0000000000..7cdc14685f --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.gd @@ -0,0 +1,5 @@ +enum MyEnum {} + +func test(): + var e: E + const E = MyEnum diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out new file mode 100644 index 0000000000..e1d5837f32 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_before_declared.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Local constant "E" is not resolved at this point. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd new file mode 100644 index 0000000000..68cf5efd8b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.gd @@ -0,0 +1,5 @@ +enum MyEnum {} + +func test(): + var E = MyEnum + var e: E diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out new file mode 100644 index 0000000000..b1f4e7a2c8 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_const.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Local variable "E" cannot be used as a type. diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd new file mode 100644 index 0000000000..ac446183cb --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.gd @@ -0,0 +1,5 @@ +enum MyEnum {A} + +func test(): + const E = MyEnum.A + var e: E diff --git a/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out new file mode 100644 index 0000000000..c3c2c8ca2f --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/errors/local_const_as_type_use_not_type.out @@ -0,0 +1,2 @@ +GDTEST_ANALYZER_ERROR +Local constant "E" is not a valid type. -- cgit v1.2.3