[vala/staging] vala: Improve error message for arrays as type arguments



commit 4e34272c34ef558663af19414a7584506cb60fc0
Author: Florian Brosch <flo brosch gmail com>
Date:   Wed Sep 3 01:37:31 2014 +0200

    vala: Improve error message for arrays as type arguments

 tests/Makefile.am                        | 1 +
 tests/generics/arrays-not-supported.test | 8 ++++++++
 vala/valasemanticanalyzer.vala           | 2 ++
 3 files changed, 11 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4d2be1385..292eea0c7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
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[]>();
+}
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index bb4f9b744..25c812dc4 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -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 ()));
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]