www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19518] New: std.range.front() returns a dchar when applied to


          Issue ID: 19518
           Summary: std.range.front() returns a dchar when applied to
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: madric gmail.com

Consider the following program:
import std.range;
void main()
        char[] data = ['a', 'b', 'c'];
        char a = data.front();

While std.range.front() works fine with most array types, there seems to be a
problem with using char[] types. The above program actually produces a compiler
onlineapp.d(5): Error: cannot implicitly convert expression `front(data)` of
type `dchar` to `char`


The workaround is to not use std.range.front(), but rather use basic array
indexing, e.g. `data[0]`.

Dec 26 2018