GNOME Bugzilla – Bug 659863
Critical warnings when accessing property in parent class
Last modified: 2017-02-18 16:20:19 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
Created attachment 197285 [details] GDB backtrace
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.
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.
(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; } }
(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.