After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 701978 - Property Default error needed
Property Default error needed
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Semantic Analyzer
0.20.x
Other Linux
: Normal trivial
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2013-06-11 07:08 UTC by Jason Smith
Modified: 2018-04-14 10:53 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Jason Smith 2013-06-11 07:08:44 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);
   }
}
Comment 1 Luca Bruno 2013-06-11 07:29:07 UTC
Why shouldn't it be allowed? Currently it calls the setter when setting the default, except it's buggy.
Comment 2 Jason Smith 2013-06-11 16:33:16 UTC
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?
Comment 3 Luca Bruno 2013-06-11 19:04:35 UTC
(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 ;)
Comment 4 Luca Bruno 2013-06-11 21:07:47 UTC
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.