[vala/0.40] vala: Do not allow += for arrays with fixed length
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Do not allow += for arrays with fixed length
- Date: Sun, 10 Nov 2019 17:06:02 +0000 (UTC)
commit 9e6db51e32e2415a7b97c15cf6e3fc1fa833bd93
Author: Florian Brosch <flo brosch gmail com>
Date: Wed Sep 17 00:17:01 2014 +0200
vala: Do not allow += for arrays with fixed length
tests/Makefile.am | 1 +
tests/arrays/fixed-length-concat-invalid.test | 6 ++++++
vala/valabinaryexpression.vala | 4 ++++
3 files changed, 11 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b9bdcafaf..9bb4923bd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -65,6 +65,7 @@ TESTS = \
arrays/class-field-length-cname.vala \
arrays/expression-bracket.test \
arrays/field-global-length-cname.vala \
+ arrays/fixed-length-concat-invalid.test \
arrays/fixed-length-non-const.test \
arrays/struct-field-length-cname.vala \
arrays/slice-invalid-start.test \
diff --git a/tests/arrays/fixed-length-concat-invalid.test b/tests/arrays/fixed-length-concat-invalid.test
new file mode 100644
index 000000000..99f24a34b
--- /dev/null
+++ b/tests/arrays/fixed-length-concat-invalid.test
@@ -0,0 +1,6 @@
+Invalid Code
+
+void main () {
+ int foo[2] = { 23, 42 };
+ foo += 4711;
+}
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index b98197e0d..356347152 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -364,6 +364,10 @@ public class Vala.BinaryExpression : Expression {
var array_type = (ArrayType) left.value_type;
+ if (array_type.inline_allocated) {
+ error = true;
+ Report.error (source_reference, "Array concatenation not supported for fixed
length arrays");
+ }
if (right.value_type == null || !right.value_type.compatible
(array_type.element_type)) {
error = true;
Report.error (source_reference, "Incompatible operand");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]