[Vala] [Genie] invalid code sometimes generated: caused by line comment indentation



I'm running Vala 0.10.0

Genie code snippet:

[indent=4]

    if i == 1
        print "one"
    else
        print "not one"
        // TODO: add error-handling code here
    print "test is done"


Generated C code:

    if (i == 1) {
        g_print ("one\n");
    } else {
        g_print ("not one\n");
        g_print ("test is done\n");
    }

Notice how "test is done" wrongly gets hoisted inside the else-block


Oddly enough, the following code snippet compiles fine:

[indent=4]

    if i == 1
        print "one"
    else
        print "not one"
        /* TODO: add error-handling code here */
    print "test is done"


this open bug also seems related:
https://bugzilla.gnome.org/show_bug.cgi?id=611085

Generally, this Genie pseudo-code

    code1
        code2
        // comment
    code3
    code4

always gets wrongly translated into this C pseudo-code

    code1 {
        code2
        code3
    }
    code4

In Genie 'code1' can be any of: for, while, if, else, when, etc.


I am using the following work-around in my Genie code:

    code1
        code2
    //  ^^ comment
    code3
    code4





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