GNOME Bugzilla – Bug 530422
invalid code from const strings as default value of properties
Last modified: 2008-10-17 12:15:45 UTC
When trying to use a const string as the default value for a property, it generates invalid C (referencing _tmpN variables which were not declared). nemequ@desktop:~/t$ cat test.vala public const string BAR = "Doesn't!\n"; public const string BAZ = "Works!\n"; public class Foo : GLib.Object { public string a { get; set; default = "Works!\n"; } public string b = "Works!\n"; public string c { get; set; default = BAR; } public string d = BAR; public string e; construct { this.e = BAZ; } } static int main(string[] args) { var foo = new Foo(); GLib.stderr.printf(foo.a); GLib.stderr.printf(foo.b); GLib.stderr.printf(foo.c); GLib.stderr.printf(foo.d); GLib.stderr.printf(foo.e); return 0; } nemequ@desktop:~/t$ valac -o test --pkg glib-2.0 test.vala test.c: In function ‘foo_constructor’: test.c:80: error: conflicting types for ‘_tmp3’ test.c:78: error: previous declaration of ‘_tmp3’ was here test.c:84: warning: assignment discards qualifiers from pointer target type test.c: In function ‘foo_init’: test.c:140: error: ‘_tmp0’ undeclared (first use in this function) test.c:140: error: (Each undeclared identifier is reported only once test.c:140: error: for each function it appears in.) test.c:141: error: ‘_tmp1’ undeclared (first use in this function) error: cc exited with status 256 Compilation failed: 1 error(s), 0 warning(s)
Confirming.
*** Bug 538776 has been marked as a duplicate of this bug. ***
2008-10-17 Jürg Billeter <j@bitron.ch> * vala/valabinaryexpression.vala: * vala/valaexpression.vala: * vala/valamemberaccess.vala: * vala/valastringliteral.vala: * gobject/valaccodegenerator.vala: Extend non-null check when managing memory, fixes bug 530422 Fixed in r1849.