digitalmars.D.bugs - [Issue 14519] New: [Enh] foreach on strings should return
- via Digitalmars-d-bugs (25/25) Apr 28 2015 https://issues.dlang.org/show_bug.cgi?id=14519
https://issues.dlang.org/show_bug.cgi?id=14519 Issue ID: 14519 Summary: [Enh] foreach on strings should return replacementDchar rather than throwing Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com Consider: safe pure nothrow nogc void bar(); void foo(string s) safe pure nothrow nogc { foreach (dchar c; s) bar(); } This fails to compile because foreach over a decoded string can throw. It also incorrectly is regarded as nogc, because the throw can allocate. Changing foreach to return replacementDchar on invalid UTF encodings fixes these problems, and makes it possible to do faster loops. --
Apr 28 2015