diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-02-17 20:56:30 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2018-02-17 20:56:30 +0100 |
commit | 30caeacecf9798d40f26f6e1cd13610615324e36 (patch) | |
tree | 76268fed51488a0662bad1fccbe329442cfd198e | |
parent | 7cdcc81d646be5fdf995df5b24478a1c7d162de0 (diff) | |
download | vala-30caeacecf9798d40f26f6e1cd13610615324e36.tar.gz |
vala: The rank of an array-initializer should match the target's rank
https://bugzilla.gnome.org/show_bug.cgi?id=744923
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/basic-types/bug744923.test | 5 | ||||
-rw-r--r-- | vala/valaarraycreationexpression.vala | 6 |
3 files changed, 12 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index ed90923e9..f7ddab646 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,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 000000000..7f2b84b9d --- /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 a43315788..3c6fb2a93 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) { |