GNOME Bugzilla – Bug 773661
Object-style construction does not set property default values on construct properties
Last modified: 2016-11-28 21:35:43 UTC
class Default : Object { public string default_id { owned get; construct; default = "default"; } public int val { get; construct; } } class Derived : Default { public Derived() { Object (val: -1); } public void do_something () { print ("Default: %s\n", this.default_id); } } int main (string[] args) { var d = new Derived (); d.do_something (); return 0; } Output: ./default Default: (null)
"Issue" is that the default properties are set in instance_init and not as part of the param spec of that property. The construct properties are set after instance init and their default overwrites the value set in instance_init
Created attachment 339135 [details] [review] Minimal test case
Created attachment 339136 [details] [review] Proposed patch
Similar problem: https://bugzilla.gnome.org/show_bug.cgi?id=734013
Actually I'd say it's the same issue
It's really the same and the proposed approach is better than mine. This evening I'll try to see if patch still applies to master and what's the result for some corner cases.
*** This bug has been marked as a duplicate of bug 734013 ***