[Vala] [Genie] Is 'unreachable code' warning spurious?



Hi guys,

I have a complex Genie function that issues a warning. I simplified it to the following code:

[indent=4]

def fn1()
    for var n = 1 to 5
        case n  // valac warning: unreachable code detected
            when 5
                return

def fn2()
    for var n = 1 to 5
        case n
            when 5
                if ( 0 == 0 )
                    return


The first function causes a Valac warning, the second is a work-around to avoid the warning.

The 'unreachable code' warning is posted against the 'case n' line.

It seems that any 'when' clause containing an unconditional 'return' or 'return value' will trigger the warning.

Is this intended Valac behavior or is it a spurious warning?




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