]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Fix array length of array returned by lambda
authorSimon Werbeck <simon.werbeck@gmail.com>
Thu, 25 Feb 2016 23:28:11 +0000 (00:28 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 5 Oct 2016 06:21:46 +0000 (08:21 +0200)
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
tests/Makefile.am
tests/delegates/bug761360.vala [new file with mode: 0644]

index 0e3a6068e257f9635297f2f31761b1808c213309..32f461a9b8bf679744a8a2f3277a5e676ade2bd5 100644 (file)
@@ -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);
 
index 941e0184b8d49c056fc288927c57926a4e1b3644..7f46a2b0b47e5acf113b9b3ebfc5e75a3c3a75f1 100644 (file)
@@ -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 (file)
index 0000000..ba90b69
--- /dev/null
@@ -0,0 +1,8 @@
+delegate int[] ArrayReturnFunc ();
+
+void main () {
+       ArrayReturnFunc f = () => { return {1, 2, 3}; };
+
+       var a = f ();
+       assert (a.length == 3);
+}