[vala/staging] vala: Avoid subsequent critical caused by invalid array type for constant



commit a35c097506e2e07ab7537fcd4ad29ea62e41f1d2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Jul 2 13:11:52 2020 +0200

    vala: Avoid subsequent critical caused by invalid array type for constant

 tests/Makefile.am                       | 1 +
 tests/constants/array-type-invalid.test | 6 ++++++
 vala/valaconstant.vala                  | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 35b610d2a..bfd7ac8e5 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 000000000..80e699977
--- /dev/null
+++ b/tests/constants/array-type-invalid.test
@@ -0,0 +1,6 @@
+Invalid Code
+
+const int[4] FOO = { 23 };
+
+void main() {
+}
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index b0beddc2b..ba0c5660c 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -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;
                                }


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