]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve error message for arrays as type arguments 4e34272c34ef558663af19414a7584506cb60fc0
authorFlorian Brosch <flo.brosch@gmail.com>
Tue, 2 Sep 2014 23:37:31 +0000 (01:37 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 29 Oct 2019 16:22:04 +0000 (17:22 +0100)
tests/Makefile.am
tests/generics/arrays-not-supported.test [new file with mode: 0644]
vala/valasemanticanalyzer.vala

index 4d2be1385f9a06d5d1a0c9c0ca13f8643acb00df..292eea0c756bbbf0d2abfe7052589197a8a644f8 100644 (file)
@@ -498,6 +498,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[]>();
+}
index bb4f9b744d4f99d00b88187ee0b85057c493ee48..25c812dc43e8a5f13f705670f673ce1316560d46 100644 (file)
@@ -1322,6 +1322,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        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 ()));
                }