GNOME Bugzilla – Bug 638310
Vala generates invalid C when accessing out param 'foo' and declaring local '_foo'
Last modified: 2011-07-28 10:46:34 UTC
valac turns this Vala into the following C: private void foo (out string? bar) { string _bar = "baz qux"; if (bar == "xyz") warning ("invalid string '%s'", bar); } => static void folks_inspect_commands_signals_foo (FolksInspectCommandsSignals* self, gchar** bar) { gchar* _bar = NULL; gchar* _tmp0_; /* XXX: second declaration of _bar, for the local variable declared in Vala */ gchar* _bar; g_return_if_fail (self != NULL); _tmp0_ = g_strdup ("baz qux"); _bar = _tmp0_; if (g_strcmp0 (_bar, "xyz") == 0) { g_warning ("command-signals.vala:198: invalid string '%s'", _bar); } _g_free0 (_bar); if (bar) { *bar = _bar; } else { _g_free0 (_bar); } } ============================== The problem is that the out parameter "bar" creates a temporary variable "_bar" in C, which conflicts with the declaration of the local variable "_bar".
commit 07ad39b7ba5db54aa9e7cc91035ff7d2c51f693b Author: Luca Bruno <lucabru@src.gnome.org> Date: Thu Jul 28 12:45:39 2011 +0200 codegen: Use _vala_ prefix for out parameters Fixes bug 638310. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.