]> 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>
Sun, 26 Jul 2020 08:37:15 +0000 (10:37 +0200)
tests/Makefile.am
tests/constants/array-type-invalid.test [new file with mode: 0644]
vala/valaconstant.vala
vala/valainitializerlist.vala

index a4ba93a1d6b4ebd4fc4e855f4a7f097666726dd3..114a2af66a68e8b1af5518514c621d752dde2a0b 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 c897cd89226a715eeae9ef13e94b9b68a685d8b3..f7d2aaf3d49683cd54fd1572d6bf8afd84892999 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 ac35abc0113d1bfca736e62ec371fe0515f8eea9..58301b6e2178325f274dddc93a5e5949a21e26ef 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 */
                        var array_type = (ArrayType) target_type;