naga icon indicating copy to clipboard operation
naga copied to clipboard

[hlsl-out] scoping issue with switch statement fallthrough

Open hasali19 opened this issue 2 years ago • 0 comments

WGSL:

fn main() {
    var x = 0;
    switch (x) {
        case -1: {
            fallthrough;
        }
        default: {
            let var_2 = i32(11632);
        }
    }
}

HLSL:

void main()
{
    int x = 0;

    int _expr2 = x;
    switch(_expr2) {
        case -1: {
            {
            }
            {
                int var_2_ = int(11632);
            }
            break;
        }
        default: {
            int var_2_1 = var_2_;
            break;
        }
    }
}

var_2_ is declared in the first case block but there is an invalid use in the default block. This looks like a recent regression since I think it was fine on an older commit of naga.

hasali19 avatar Jun 06 '22 16:06 hasali19