GNOME Bugzilla – Bug 701978
Property Default error needed
Last modified: 2018-04-14 10:53:57 UTC
When defining a property for a class default should not be used if the getter and setter are defined. An error should probably be emitted. Currently it just prints: ** (valac-0.18:32211): CRITICAL **: vala_code_node_replace_expression: assertion `self != NULL' failed Below is a simple test case that can be run. namespace Error { public struct A { public int val { get; set; } public A() { val = 55; } } public class B : Object { private A backing_a; // BUG: This is the error area. It works if I have: // public A foo // { get; set; default = A(); } // It does not work the below way and needs to emit an error message. public A foo { get { return backing_a; } set { backing_a = value; } default = A(); } public B() { } } public static void main(string[] args) { B temp; temp = new B(); stdout.printf("Value: %d\n", temp.foo.val); } }
Why shouldn't it be allowed? Currently it calls the setter when setting the default, except it's buggy.
OK. So the bug is really that it doesn't allow the default value to be set? If so should I make a separate bug ticket or can we just change this one?
(In reply to comment #2) > OK. So the bug is really that it doesn't allow the default value to be set? If > so should I make a separate bug ticket or can we just change this one? The bug is that the default value must be set, because there's a setter anyway. This bug report is fine ;)
commit 73e553ac3488d641fb08b275bcf2636e3cf0de67 Author: Luca Bruno <lucabru@src.gnome.org> Date: Tue Jun 11 23:02:44 2013 +0200 codegen: Support non-auto property initializer in gobjects Fixes bug 701978 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.