bug in foreach continue

Hussien via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 16 18:34:52 PDT 2017


foreach (y; aliasSeqOf!["a", "b", "c"])
{
static if (y == "a") { }
else
  pragma(msg, y);
}

works but

foreach (y; aliasSeqOf!["a", "b", "c"])
{
static if (y == "a") continue
pragma(msg, y);
}

fails.

Seems like continue needs to be static aware.

This leads to subtle bugs where one thinks the continue 
statement(like in in a runtime foreach loop, should jump to to 
the next iteration, but it doesn't.

The runtime versions of the code work identically, and so should 
the static versions.



More information about the Digitalmars-d-learn mailing list