Skip to content

Switch statement tests #3058

@samsinsane

Description

@samsinsane

I encountered this bug the other day in both Chrome and Firefox, and I'm not entirely sure what to do about it. The default case is not executed in this scenario:

switch(0)
{
  default:
    ...
}

Bit of backstory: At work we use Shader Conductor to convert our DirectX shaders to Metal, OpenGL, and OpenGL ES/WebGL shaders. This pattern seems to be generated due to functions being inlined into main, and the functions with multiple returns end up generating this switch statement. For what it's worth, this pattern worked fine for OpenGL on Windows, and Metal on macOS.

I was able to workaround this issue by replacing default with case 0, but figured I should at least report this somewhere and I stumbled across this repo while trying to find out if this was "by design" in WebGL. Since I couldn't find anything saying that default statements can be ignored under certain conditions, and since it seems to be browser independent, I figure that it's a conformance test problem and should be reported here? Unfortunately, I don't really have that much time to dedicate to this, so chasing individual browser vendors around on this isn't feasible, but I can add more tests to switch-case.html if that gets the ball rolling?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions