[Issue 12864] New: can no longer use toLower in string switch case

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 5 20:45:50 PDT 2014


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

          Issue ID: 12864
           Summary: can no longer use toLower in string switch case
           Product: D
           Version: unspecified
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: code at dawg.eu

cat > bug.d << CODE
import std.string;

enum name = "Name";

void color(string s)
{
    switch (s)
    {
    case name.toLower():
        break;

    default:
        break;
    }
}
CODE

dmd -c bug
----
bug.d(9): Error: case must be a string or an integral constant, not ['n', 'a',
'm', 'e']
----

This is because toLower now uses appender internally.
The bug seems to be that CTFE doesn't recognize char arrays from appender as
strings.

--


More information about the Digitalmars-d-bugs mailing list