Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Rules about "break" inside "continuing" are strange #1867

@kvark

Description

@kvark

This is a very elaborate set of rules:

When a break statement is placed such that it would exit from a loop’s § 7.3.8 Continuing Statement, then:
    The break statement must appear as either:
        The only statement in the if clause of an if statement that has:
            no else clause or an empty else clause
            no elseif clauses
        The only statement in the else clause of an if statement that has an empty if clause and no elseif clauses.
    That if statement must appear last in the continuing clause.

It's basically "no break inside continue, unless at the very end behind an if".

Would it make sense to express this via language syntax instead?

var a: i32 = 2;
var i: i32 = 0;
loop {
  let step: i32 = 1;
  if (i % 2 == 0) { continue; }
  a = a * 2;
  continuing {
    i = i + step;
  } unless (i>=4);  // <--- HERE
}

Metadata

Metadata

Assignees

Labels

wgslWebGPU Shading Language Issues

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions