]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: The rank of an array-initializer should match the target's rank
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 17 Feb 2018 19:56:30 +0000 (20:56 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 16 Apr 2018 19:03:56 +0000 (21:03 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=744923

tests/Makefile.am
tests/basic-types/bug744923.test [new file with mode: 0644]
vala/valaarraycreationexpression.vala

index f0b59b9fcaf841156b9f5f813001e6eb17a6564f..ea930d585de79ae6736596da536d79199379d7fe 100644 (file)
@@ -41,6 +41,7 @@ TESTS = \
        basic-types/bug686336.vala \
        basic-types/bug729907.vala \
        basic-types/bug731017.vala \
+       basic-types/bug744923.test \
        basic-types/bug761307.vala \
        basic-types/bug761736.vala \
        basic-types/bug771626.test \
diff --git a/tests/basic-types/bug744923.test b/tests/basic-types/bug744923.test
new file mode 100644 (file)
index 0000000..7f2b84b
--- /dev/null
@@ -0,0 +1,5 @@
+Invalid Code
+
+void main () {
+       int[,] i = {};
+}
index 58947842118a4a29b674ea6a28a8f1a8d104f3d3..4b9aa6cc74af3f7c7583b3df820624baca092170 100644 (file)
@@ -198,6 +198,12 @@ public class Vala.ArrayCreationExpression : Expression {
                        if (ret == -1) {
                                error = true;
                        }
+
+                       if (calc_sizes.size != rank) {
+                               error = true;
+                               var actual_type = new ArrayType (element_type, calc_sizes.size, source_reference);
+                               Report.error (initlist.source_reference, "Expected initializer for `%s' but got `%s'".printf (target_type.to_string (), actual_type.to_string ()));
+                       }
                }
 
                if (sizes.size > 0) {