]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Avoid subsequent critical caused by invalid array type for constant
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 2 Jul 2020 11:11:52 +0000 (13:11 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 2 Jul 2020 12:03:43 +0000 (14:03 +0200)
tests/Makefile.am
tests/constants/array-type-invalid.test [new file with mode: 0644]
vala/valaconstant.vala
vala/valainitializerlist.vala

index 35b610d2ab45e703cb09869d72e51717b531e88d..bfd7ac8e54c44e20019a260c8349ee77d2245dc3 100644 (file)
@@ -75,6 +75,7 @@ TESTS = \
        basic-types/bug777697.test \
        basic-types/bug787152.vala \
        basic-types/bug788775.vala \
+       constants/array-type-invalid.test \
        constants/glog.vala \
        arrays/cast-silent-invalid.test \
        arrays/class-field-length-cname.vala \
diff --git a/tests/constants/array-type-invalid.test b/tests/constants/array-type-invalid.test
new file mode 100644 (file)
index 0000000..eb894d5
--- /dev/null
@@ -0,0 +1,6 @@
+Invalid Code
+
+const int[,4] FOO = { { 23 }, { 42 } };
+
+void main() {
+}
index b0beddc2b3d7ff437d80310d353c13f610130bad..ba0c5660c647e1b149243922800832a774b18478 100644 (file)
@@ -131,7 +131,7 @@ public class Vala.Constant : Symbol {
                        } else {
                                value.target_type = type_reference;
 
-                               if (!value.check (context)) {
+                               if (!value.check (context) || type_reference.error) {
                                        error = true;
                                        return false;
                                }
index 08ced48aa80e168099c45b25ba9b9c2a53f9b28c..93411e4702b5e09808996c2e676ea3dff46bca5b 100644 (file)
@@ -141,6 +141,9 @@ public class Vala.InitializerList : Expression {
                        error = true;
                        Report.error (source_reference, "initializer list used for unknown type");
                        return false;
+               } else if (target_type.error) {
+                       error = true;
+                       return false;
                } else if (target_type is ArrayType) {
                        /* initializer is used as array initializer */
                        unowned ArrayType array_type = (ArrayType) target_type;