]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Multi-dimensional params-array not allowed
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 22 Sep 2021 11:44:35 +0000 (13:44 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 22 Sep 2021 11:44:35 +0000 (13:44 +0200)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1230

tests/Makefile.am
tests/methods/params-array-multi-dimensional.test [new file with mode: 0644]
vala/valaparameter.vala

index ed1ef59801c997c0f6760ba1be132dec22ebc526..f77a696f5f7fea9d3830753970062a7258bcd04c 100644 (file)
@@ -232,6 +232,7 @@ TESTS = \
        methods/nowrapper-no-vfunc.test \
        methods/params-array.vala \
        methods/params-array-abstract.test \
+       methods/params-array-multi-dimensional.test \
        methods/params-array-preceding.test \
        methods/params-array-with-throws.vala \
        methods/print-attribute.vala \
diff --git a/tests/methods/params-array-multi-dimensional.test b/tests/methods/params-array-multi-dimensional.test
new file mode 100644 (file)
index 0000000..d66d5ab
--- /dev/null
@@ -0,0 +1,7 @@
+Invalid Code
+
+void foo (params string[,] strvv) {
+}
+
+void main () {
+}
index 41a59da6105a80a12ff9363eefbaa9f23d21456d..7bbb2cedbd787c367da0b56015c9cdc63300b3d0 100644 (file)
@@ -152,10 +152,16 @@ public class Vala.Parameter : Variable {
                if (!ellipsis) {
                        variable_type.check (context);
 
-                       if (params_array && !(variable_type is ArrayType)) {
-                               error = true;
-                               Report.error (source_reference, "parameter array expected");
-                               return false;
+                       if (params_array) {
+                               if (!(variable_type is ArrayType)) {
+                                       error = true;
+                                       Report.error (source_reference, "parameter array expected");
+                                       return false;
+                               } else if (((ArrayType) variable_type).rank != 1) {
+                                       error = true;
+                                       Report.error (source_reference, "multi-dimensional parameter array not allowed");
+                                       return false;
+                               }
                        }
 
                        if (has_attribute_argument ("CCode", "scope") && variable_type is DelegateType) {