Skip to content

Static break and continue #23302

Description

@Bolpat

A static foreach statement (and only that, not a foreach statement over a compile-time sequence) should permit static break and static continue statements, possibly labeled to discriminate which static foreach is meant. The unlabeled version is always admissible and refers to the innermost static foreach. Due to the static keyword, conflation with a non-static loop or other construct is unlikely.

In every loop iteration, it generates code. Essentially, the loop body is copied and the iteration variable replaced by its value. If it contains any static break or static continue that refer to the current loop, any static foreach and static if declarations must be be handled. If any static break or static continue remain, the first takes precedent. If it is a static break, anything after it must be discarded and the loop must not generate another instantiation. If it’s a static continue, anything after it must be discarded before the next loop iteration.

(Anything said for static foreach also applies to static foreach_reverse.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions