https://issues.dlang.org/show_bug.cgi?id=15459

ZombineDev <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from ZombineDev <[email protected]> ---
When you're iterating any kind of string (char, wchar or dchar based) the
element type is always dchar. This special case for narrow strings (UTF-8 and
UTF-16) is also known as UTF autodecoding. You can see this for yourself if you
change `somefunc` into a template and add a pragma statement to make the
compiler emit an information message about the type of `c` for each
instantiation of the function:

auto somefunc(C)(C c)
{
    pragma (msg, C);
    return c;
}

See also: http://dlang.org/phobos/std_range_primitives.html#.ElementType,
http://dlang.org/phobos/std_range_primitives.html#.front and
http://dlang.org/glossary.html#narrow strings

This is still a valid bug report, because the compiler should refuse to compile
this code.

--

Reply via email to