[vala/0.36] vala: The rank of an array-initializer should match the target's rank
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] vala: The rank of an array-initializer should match the target's rank
- Date: Fri, 2 Mar 2018 16:19:50 +0000 (UTC)
commit af8b3114056d3baa5ae7422667f83acc36bd651c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Feb 17 20:56:30 2018 +0100
vala: The rank of an array-initializer should match the target's rank
https://bugzilla.gnome.org/show_bug.cgi?id=744923
tests/Makefile.am | 1 +
tests/basic-types/bug744923.test | 5 +++++
vala/valaarraycreationexpression.vala | 6 ++++++
3 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c77c2fb..d18385d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,6 +41,7 @@ TESTS = \
basic-types/bug686336.vala \
basic-types/bug729907.vala \
basic-types/bug731017.vala \
+ basic-types/bug744923.test \
basic-types/bug756376.vala \
basic-types/bug761307.vala \
basic-types/bug761736.vala \
diff --git a/tests/basic-types/bug744923.test b/tests/basic-types/bug744923.test
new file mode 100644
index 0000000..7f2b84b
--- /dev/null
+++ b/tests/basic-types/bug744923.test
@@ -0,0 +1,5 @@
+Invalid Code
+
+void main () {
+ int[,] i = {};
+}
diff --git a/vala/valaarraycreationexpression.vala b/vala/valaarraycreationexpression.vala
index a433157..3c6fb2a 100644
--- a/vala/valaarraycreationexpression.vala
+++ b/vala/valaarraycreationexpression.vala
@@ -212,6 +212,12 @@ public class Vala.ArrayCreationExpression : Expression {
if (ret == -1) {
error = true;
}
+
+ if (calc_sizes.size != rank) {
+ error = true;
+ var actual_type = new ArrayType (element_type, calc_sizes.size,
source_reference);
+ Report.error (initlist.source_reference, "Expected initializer for `%s' but
got `%s'".printf (target_type.to_string (), actual_type.to_string ()));
+ }
}
if (sizes.size > 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]