From: Rico Tzschichholz Date: Sun, 7 Mar 2021 13:20:43 +0000 (+0100) Subject: vala: Check array type of declarations for errornous type-arguments X-Git-Tag: 0.51.91~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07c1f094fea124921589f77a3560a96e5ebbe86b;p=thirdparty%2Fvala.git vala: Check array type of declarations for errornous type-arguments --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 32bd92fc5..98d4e386a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -887,6 +887,7 @@ TESTS = \ semantic/array-stacked.test \ semantic/array-incompatible-initializer.test \ semantic/array-incompatible-initializer2.test \ + semantic/array-invalid-type-argument.test \ semantic/assignment-element-incompatible-ownership.test \ semantic/assignment-element-incompatible-type.test \ semantic/assignment-fixed-array-length.test \ diff --git a/tests/semantic/array-invalid-type-argument.test b/tests/semantic/array-invalid-type-argument.test new file mode 100644 index 000000000..89e6d4039 --- /dev/null +++ b/tests/semantic/array-invalid-type-argument.test @@ -0,0 +1,8 @@ +Invalid Code + +class Foo { +} + +void main () { + Foo[] foo = null; +} diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala index 44b01b0f2..2468edf20 100644 --- a/vala/valaarraytype.vala +++ b/vala/valaarraytype.vala @@ -326,7 +326,18 @@ public class Vala.ArrayType : ReferenceType { } } - return element_type.check (context); + if (!element_type.check (context)) { + error = true; + return false; + } + + // check whether there is the expected amount of type-arguments + if (!element_type.check_type_arguments (context, true)) { + error = true; + return false; + } + + return true; } public override DataType get_actual_type (DataType? derived_instance_type, List? method_type_arguments, CodeNode? node_reference) {