]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve error message for arrays as type arguments
authorFlorian Brosch <flo.brosch@gmail.com>
Tue, 2 Sep 2014 23:37:31 +0000 (01:37 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 Nov 2019 11:11:48 +0000 (12:11 +0100)
codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/generics/arrays-not-supported.test [new file with mode: 0644]

index 776562087fac3ce49c8b6d66c51a224ba9276aa7..54bf70bc51bd62a4ba866d4c804b1277b64c2838 100644 (file)
@@ -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 ()));
                }
index 6cc135dac0c44092643481cd6726bbe23a55b176..d802cbc7a865328e14b20140a74d4ce2f1a8a601 100644 (file)
@@ -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 (file)
index 0000000..39bce90
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid Code
+
+void foo<G>(G g = null) {
+}
+
+void main () {
+       foo<int[]>();
+}