[Vala] "Assignment from incompatible pointer type" while using delegate/lambda



Hi,

While experimenting with delegates/lambda expressions, the code below
results in a warning "assignment from incompatible pointer type" during
the C compilation phase:

    /**********/
    delegate int RandomGenerator();
    
    RandomGenerator trick_dice(int result) {
        return () => { return result; };
    }
    
    void main() {
        RandomGenerator rg = trick_dice(3);
    
        for(int i = 0; i < 10; ++i)
            stdout.printf("%3d: %d\n", i, rg());
    }
    /**********/

    sh$ valac curry.vala 
    /home/sylvain/curry.vala.c: In function 'trick_dice':
    /home/sylvain/curry.vala.c:62: warning: assignment from
    incompatible pointer type

I don't understand what's wrong here. But I tried it with Vala 0.8.1,
0.10.3 and 0.15.1, having each time the exact same result. Apart from
the warning, the code worked as expected.


- Sylvain




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]