]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add type declaration for implicit temporary local variable
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 18 Sep 2021 21:30:31 +0000 (23:30 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 22 Sep 2021 13:26:46 +0000 (15:26 +0200)
codegen/valaccodebasemodule.vala
tests/Makefile.am
tests/delegates/implicit-local-variable.vala [new file with mode: 0644]

index 14aa846f98eb75d6772fcf3940d167560baf982b..c65fda753640cbb9cf13795e22ce9d7981fc280a 100644 (file)
@@ -3912,6 +3912,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
        }
 
        public void emit_temp_var (LocalVariable local, bool on_error = false) {
+               generate_type_declaration (local.variable_type, cfile);
+
                var init = (!local.name.has_prefix ("*") && local.init);
                if (is_in_coroutine ()) {
                        closure_struct.add_field (get_ccode_name (local.variable_type), local.name, 0, get_ccode_declarator_suffix (local.variable_type));
index 3671f3312dbffd2808dfad22b5a17d90e1b20703..fbc25c3bc9f40e23fdc4b8b066950d7072c7826f 100644 (file)
@@ -397,6 +397,7 @@ TESTS = \
        delegates/fields.vala \
        delegates/fields-no-target.vala \
        delegates/gclosure-conversion.vala \
+       delegates/implicit-local-variable.vala \
        delegates/incompatible.test \
        delegates/incompatible-assignment.test \
        delegates/incompatible-initializer.test \
diff --git a/tests/delegates/implicit-local-variable.vala b/tests/delegates/implicit-local-variable.vala
new file mode 100644 (file)
index 0000000..ffe1d31
--- /dev/null
@@ -0,0 +1,6 @@
+void main () {
+       SourceFuncs foo = { null, null, () => { return false; }, null };
+       Source bar = null;
+
+       foo.dispatch (bar, null);
+}