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.
Comment #1 by code — 2014-06-06T03:46:33Z
Used to work with 2.065
Comment #2 by yebblies — 2014-06-08T00:05:45Z
Comment #3 by github-bugzilla — 2014-06-08T02:08:49Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/2a0cb370c7670b3292c79fce50c429efa6e545d5 Fix Issue 12864 - can no longer use toLower in string switch case https://github.com/D-Programming-Language/dmd/commit/5a8c53d5ea4b8085ee5bfddb943b09d1710f360f Merge pull request #3644 from yebblies/issue12864 [REG] Issue 12864 - can no longer use toLower in string switch case