[vala/0.48] vala: Avoid subsequent critical caused by invalid array type for constant
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Avoid subsequent critical caused by invalid array type for constant
- Date: Wed, 15 Jul 2020 07:09:56 +0000 (UTC)
commit 68dad325a1110c71ac802aa85f954f6ca922c5fd
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 +-
vala/valainitializerlist.vala | 3 +++
4 files changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5569f7428..308ca8ef7 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..eb894d519
--- /dev/null
+++ b/tests/constants/array-type-invalid.test
@@ -0,0 +1,6 @@
+Invalid Code
+
+const int[,4] FOO = { { 23 }, { 42 } };
+
+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;
}
diff --git a/vala/valainitializerlist.vala b/vala/valainitializerlist.vala
index 08ced48aa..93411e470 100644
--- a/vala/valainitializerlist.vala
+++ b/vala/valainitializerlist.vala
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]