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 659863 - Critical warnings when accessing property in parent class
Critical warnings when accessing property in parent class
Status: RESOLVED NOTABUG
Product: vala
Classification: Core
Component: general
0.14.x
Other Linux
: Immediate blocker
: ---
Assigned To: Vala maintainers
Vala maintainers
regression test-case wrong-code criti...
Depends on:
Blocks:
 
 
Reported: 2011-09-22 19:44 UTC by Sebastian Pölsterl
Modified: 2017-02-18 16:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (224 bytes, text/x-vala)
2011-09-22 19:44 UTC, Sebastian Pölsterl
Details
GDB backtrace (32.77 KB, text/plain)
2011-09-22 19:45 UTC, Sebastian Pölsterl
Details
sample.vala -- GObject properties base.prop v this.prop (638 bytes, text/plain)
2012-02-12 10:31 UTC, Mike Massonnet
Details

Description Sebastian Pölsterl 2011-09-22 19:44:56 UTC
Created attachment 197284 [details]
Test case

Compiling the attached code with valac 0.14 causes a couple of critical warnings:

** (valac:12565): CRITICAL **: vala_target_value_set_value_type: assertion `self != NULL' failed

** (valac:12565): CRITICAL **: vala_ccode_base_module_store_temp_value: assertion `initializer != NULL' failed

** (valac:12565): CRITICAL **: vala_ccode_function_add_assignment: assertion `right != NULL' failed
Comment 1 Sebastian Pölsterl 2011-09-22 19:45:30 UTC
Created attachment 197285 [details]
GDB backtrace
Comment 2 Jürg Billeter 2011-09-29 17:58:01 UTC
valac 0.14 appears to generate wrong C code for valid Vala code. In your test case, you can replace 'base' with 'this' as a workaround.
Comment 3 Mike Massonnet 2012-02-12 10:31:45 UTC
Created attachment 207383 [details]
sample.vala -- GObject properties base.prop v this.prop

Using "this" is not needed, the problem really happens when you put a new property in a subclass with the same name. Sadly there is no workaround for this, apart from rewriting property names.
Comment 4 Daniel Espinosa 2017-02-18 15:55:08 UTC
(In reply to Sebastian Pölsterl from comment #0)
> Created attachment 197284 [details]
> Test case
> 
> Compiling the attached code with valac 0.14 causes a couple of critical
> warnings:
> 
> ** (valac:12565): CRITICAL **: vala_target_value_set_value_type: assertion
> `self != NULL' failed
> 
> ** (valac:12565): CRITICAL **: vala_ccode_base_module_store_temp_value:
> assertion `initializer != NULL' failed
> 
> ** (valac:12565): CRITICAL **: vala_ccode_function_add_assignment: assertion
> `right != NULL' failed

This example have different issues. You should use variable names of base class as if they declared in your current class; avoid to use *base*, it is not necessary and confuse code generator.

May is not the intention, just as example, but an abstract class should provide at least one abstract property or method.

This is the code (keeping your abstract keyword):

public abstract class Channel : Object {
    public string Name {get; set;}
}

public class CableChannel : Channel {
    public string to_string () {
        return Name;
    }

}
Comment 5 Daniel Espinosa 2017-02-18 16:20:19 UTC
(In reply to Mike Massonnet from comment #3)
> Created attachment 207383 [details]
> sample.vala -- GObject properties base.prop v this.prop
> 
> Using "this" is not needed, the problem really happens when you put a new
> property in a subclass with the same name. Sadly there is no workaround for
> this, apart from rewriting property names.

Is not recommended to declare a property with same type and name in derived classes, because you can use your base class's property. This is redundant and should be considered a programming error in Vala.

In this example, declare a property with same type and name in a derived class and try to access base class's property, this should be avoided using a different property's name.