digitalmars.D.bugs - [Issue 19518] New: std.range.front() returns a dchar when applied to
- d-bugmail puremagic.com (33/33) Dec 26 2018 https://issues.dlang.org/show_bug.cgi?id=19518
https://issues.dlang.org/show_bug.cgi?id=19518 Issue ID: 19518 Summary: std.range.front() returns a dchar when applied to char[] 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 error: ``` 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