Bug 12864 – can no longer use toLower in string switch case
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-06-06T03:45:00Z
Last change time
2015-06-09T05:15:22Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2014-06-06T03:45:50Z
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.