www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20139] New: isInputRange!string is false in betterC


          Issue ID: 20139
           Summary: isInputRange!string is false in betterC
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

The following assertion fails when compiling with -betterC:

import std.range.primitives;
static assert(isInputRange!string);

The cause is the narrow-string version of std.range.primitives.front [1], which
calls std.utf.decode [2] on the start of the string. Because decode throws a
UTFException on invalid input, it does not compile with betterC.

[1] https://dlang.org/phobos/std_range_primitives.html#.front
[2] https://dlang.org/phobos/std_utf.html#decode

Aug 18 2019