[vala/wip/fixed-arrays: 1/2] valaparser: Don't allow to declare array parameters with "type array[]"
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/fixed-arrays: 1/2] valaparser: Don't allow to declare array parameters with "type array[]"
- Date: Tue, 11 Oct 2016 15:36:19 +0000 (UTC)
commit dd4bfc75c5fe5eaf97074d2a76f24b78ff0fc387
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Oct 11 17:27:01 2016 +0200
valaparser: Don't allow to declare array parameters with "type array[]"
It is required to have a fixed length like "type array[3]".
https://bugzilla.gnome.org/show_bug.cgi?id=641308
tests/Makefile.am | 1 +
tests/basic-types/bug641308.test | 7 +++++++
vala/valaparser.vala | 7 ++++++-
3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a9d0c18..d7a97c1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -28,6 +28,7 @@ TESTS = \
basic-types/bug596637.vala \
basic-types/bug596785.vala \
basic-types/bug632322.vala \
+ basic-types/bug641308.test \
basic-types/bug643612.vala \
basic-types/bug644046.vala \
basic-types/bug647222.vala \
diff --git a/tests/basic-types/bug641308.test b/tests/basic-types/bug641308.test
new file mode 100644
index 0000000..b530077
--- /dev/null
+++ b/tests/basic-types/bug641308.test
@@ -0,0 +1,7 @@
+Invalid Code
+
+void foo (int i[]) {
+}
+
+void main () {
+}
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 3cbc561..43376df 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -3266,7 +3266,12 @@ public class Vala.Parser : CodeVisitor {
}
string id = parse_identifier ();
- type = parse_inline_array_type (type);
+ var array_type = parse_inline_array_type (type);
+ if (!(type is ArrayType) && (array_type is ArrayType) && !((ArrayType)
array_type).fixed_length) {
+ throw new ParseError.SYNTAX (get_error ("invalid array parameter declaration"));
+ } else {
+ type = array_type;
+ }
var param = new Parameter (id, type, get_src (begin));
set_attributes (param, attrs);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]