[Issue 19518] New: std.range.front() returns a dchar when applied to char[]
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Dec 26 23:34:55 UTC 2018
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 at puremagic.com
Reporter: madric at 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]`.
--
More information about the Digitalmars-d-bugs
mailing list