From: Rico Tzschichholz Date: Sat, 18 Sep 2021 21:30:31 +0000 (+0200) Subject: codegen: Add type declaration for implicit temporary local variable X-Git-Tag: 0.48.20~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b68e0b8d67a12587447fb24b9742cfd11dfb524;p=thirdparty%2Fvala.git codegen: Add type declaration for implicit temporary local variable --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index e69dacc3e..dd753a1cc 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -3839,6 +3839,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)); diff --git a/tests/Makefile.am b/tests/Makefile.am index 83dbff3b5..1d823ca11 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -394,6 +394,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 index 000000000..ffe1d3175 --- /dev/null +++ b/tests/delegates/implicit-local-variable.vala @@ -0,0 +1,6 @@ +void main () { + SourceFuncs foo = { null, null, () => { return false; }, null }; + Source bar = null; + + foo.dispatch (bar, null); +}