diff options
author | Florian Brosch <flo.brosch@gmail.com> | 2014-09-03 01:37:31 +0200 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2019-11-07 12:11:48 +0100 |
commit | fe7c88fe4360084ad0f239413057f6671c9b422f (patch) | |
tree | 1d01ef09464f752e6509de90f141882aca3752b5 | |
parent | 1046e3be73a85de301b41f7f977c02d5c2409ae7 (diff) | |
download | vala-fe7c88fe4360084ad0f239413057f6671c9b422f.tar.gz |
vala: Improve error message for arrays as type arguments
-rw-r--r-- | codegen/valaccodebasemodule.vala | 2 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/generics/arrays-not-supported.test | 8 |
3 files changed, 11 insertions, 0 deletions
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 776562087..54bf70bc5 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -4688,6 +4688,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { if (delegate_type.delegate_symbol.has_target) { Report.error (type_arg.source_reference, "Delegates with target are not supported as generic type arguments"); } + } else if (type_arg is ArrayType) { + Report.error (type_arg.source_reference, "Arrays are not supported as generic type arguments"); } else { Report.error (type_arg.source_reference, "`%s' is not a supported generic type argument, use `?' to box value types".printf (type_arg.to_string ())); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 6cc135dac..d802cbc7a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -484,6 +484,7 @@ TESTS = \ asynchronous/variadic-invalid.test \ asynchronous/variadic-invalid-2.test \ asynchronous/yield.vala \ + generics/arrays-not-supported.test \ generics/constructor-chain-up.vala \ generics/inference-static-function.vala \ generics/parameter-sizeof-initializer.vala \ diff --git a/tests/generics/arrays-not-supported.test b/tests/generics/arrays-not-supported.test new file mode 100644 index 000000000..39bce9001 --- /dev/null +++ b/tests/generics/arrays-not-supported.test @@ -0,0 +1,8 @@ +Invalid Code + +void foo<G>(G g = null) { +} + +void main () { + foo<int[]>(); +} |