这是indexloc提供的服务,不要输入任何密码
Skip to content

Valid or invalid: Return statement in the middle of a function body #996

@sarahM0

Description

@sarahM0

Is it valid to have dead code after return statement? For example:
fn func -> void {return; var a:i32 = 1; return;}

Ps. we know this is valid:
fn func -> void { if (a) { return; } var a:i32 = 1; return;}

Initial thoughts: Return must come last in its block. (Might have usability issues, ie. hacking code and wanting to return in the middle of block as we don't have if defs and so on.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionwgslWebGPU Shading Language Issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions