On Tue, Nov 11, 2014 at 11:17 AM, Виталий Кирсанов <krokozia...@gmail.com>
wrote:

> Ok, there was a bug in my code but the reaction of vala is curious. My code
> did something like this:
>
> public class Foo
> {
>     int i;
>
>     public Foo.from(int i)
>     {
>         this.i = i;
>     }
> }
>
> public class Bar
> {
>     Foo         f;
>
>     public Bar()
>     {
>         assert( this != null );
>         f.from(1);                         // this line causes the trouble
>     }
> }
>
> int main(string[] argv)
> {
>     var b = new Bar();
>     return 0;
> }
>
>
> This program fails in the following way:
>
> **
> ERROR:/net/tieto/home/vkirsan/sandbit/test.vala.c:305:bar_construct:
> assertion failed: (this != null)
> Abort
>

If I understand it correctly, the problem is not the assertion you "see",
but the assertion that
GObject uses for sanity check. In this case, "f.from(1)" is invalid syntax
since you haven't
initialized "f". A possible fix is:

f = new Foo.from(1);

It would be nice if the error message were less convoluted... (Instead of
talking
about the .c generated filed, it talked about the vala code in which the
error originates.

_______________________________________________
> vala-list mailing list
> vala-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/vala-list
>
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to