[vala/0.46] vala: Use correct value-type for ArrayCreationExpression used as argument
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Use correct value-type for ArrayCreationExpression used as argument
- Date: Mon, 22 Jun 2020 09:07:06 +0000 (UTC)
commit eb5027cee4c2d7fc68517dded35b268d8657ef9c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Jun 15 20:18:11 2020 +0200
vala: Use correct value-type for ArrayCreationExpression used as argument
Copy fixed_length and inline_allocated attributes from formal-target-type.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1009
tests/Makefile.am | 1 +
tests/methods/parameter-fixed-array-initializer.vala | 20 ++++++++++++++++++++
vala/valaarraycreationexpression.vala | 4 ++++
3 files changed, 25 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6892737ec..cbcbb188f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -128,6 +128,7 @@ TESTS = \
methods/contains.vala \
methods/extern.vala \
methods/iterator.vala \
+ methods/parameter-fixed-array-initializer.vala \
methods/parameter-ref-array-resize.vala \
methods/prepostconditions.vala \
methods/prepostconditions-captured.vala \
diff --git a/tests/methods/parameter-fixed-array-initializer.vala
b/tests/methods/parameter-fixed-array-initializer.vala
new file mode 100644
index 000000000..516f1f36b
--- /dev/null
+++ b/tests/methods/parameter-fixed-array-initializer.vala
@@ -0,0 +1,20 @@
+struct Bar {
+ int i;
+ double d;
+}
+
+void foo (int a[3]) {
+ assert (a[2] == 4711);
+}
+
+void bar (Bar b[3]) {
+ assert (b[2].i == 23);
+ assert (b[2].d == 47.11);
+}
+
+void main () {
+ foo ({ 23, 42, 4711 });
+
+ Bar b = { 23, 47.11 };
+ bar ({b, b, b});
+}
diff --git a/vala/valaarraycreationexpression.vala b/vala/valaarraycreationexpression.vala
index 71683cf4e..4d7425550 100644
--- a/vala/valaarraycreationexpression.vala
+++ b/vala/valaarraycreationexpression.vala
@@ -325,6 +325,10 @@ public class Vala.ArrayCreationExpression : Expression {
value_type = new ArrayType (element_type, rank, source_reference);
((ArrayType) value_type).length_type = length_type.copy ();
+ if (formal_target_type is ArrayType) {
+ ((ArrayType) value_type).fixed_length = ((ArrayType) formal_target_type).fixed_length;
+ ((ArrayType) value_type).inline_allocated = ((ArrayType)
formal_target_type).inline_allocated;
+ }
value_type.value_owned = true;
if (!value_type.check (context)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]