[vala] codegen: Fix array length of array returned by lambda
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix array length of array returned by lambda
- Date: Wed, 5 Oct 2016 06:49:40 +0000 (UTC)
commit 566ff81b821775c6e178c8c90bcac95d08436c91
Author: Simon Werbeck <simon werbeck gmail com>
Date: Fri Feb 26 00:28:11 2016 +0100
codegen: Fix array length of array returned by lambda
This ensures that the right default values are used for missing ccode
attributes.
https://bugzilla.gnome.org/show_bug.cgi?id=761360
codegen/valaccodebasemodule.vala | 6 +++---
tests/Makefile.am | 1 +
tests/delegates/bug761360.vala | 8 ++++++++
3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 0e3a606..32f461a 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5495,9 +5495,9 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
var delegate_type = (DelegateType) lambda.target_type;
var d = delegate_type.delegate_symbol;
- lambda.method.set_attribute_bool ("CCode", "array_length", d.get_attribute_bool ("CCode",
"array_length"));
- lambda.method.set_attribute_bool ("CCode", "array_null_terminated", d.get_attribute_bool
("CCode", "array_null_terminated"));
- lambda.method.set_attribute_string ("CCode", "array_length_type", d.get_attribute_string
("CCode", "array_length_type"));
+ lambda.method.set_attribute_bool ("CCode", "array_length", get_ccode_array_length (d));
+ lambda.method.set_attribute_bool ("CCode", "array_null_terminated",
get_ccode_array_null_terminated (d));
+ lambda.method.set_attribute_string ("CCode", "array_length_type", get_ccode_array_length_type
(d));
lambda.accept_children (this);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 941e018..7f46a2b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -129,6 +129,7 @@ TESTS = \
delegates/bug639751.vala \
delegates/bug659778.vala \
delegates/bug703804.vala \
+ delegates/bug761360.vala \
objects/chainup.vala \
objects/classes.vala \
objects/generics.vala \
diff --git a/tests/delegates/bug761360.vala b/tests/delegates/bug761360.vala
new file mode 100644
index 0000000..ba90b69
--- /dev/null
+++ b/tests/delegates/bug761360.vala
@@ -0,0 +1,8 @@
+delegate int[] ArrayReturnFunc ();
+
+void main () {
+ ArrayReturnFunc f = () => { return {1, 2, 3}; };
+
+ var a = f ();
+ assert (a.length == 3);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]