Bug 15396 – static immutable not recognized as constant within switch statement
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-12-02T18:20:00Z
Last change time
2016-01-03T14:02:37Z
Keywords
rejects-valid
Assigned to
nobody
Creator
mathias.lang
Comments
Comment #0 by mathias.lang — 2015-12-02T18:20:04Z
Test case:
`````
static immutable Foo = "Foobar";
void main (string[] args)
{
foreach (arg; args)
{
switch (arg)
{
case Foo:
assert(0);
default:
continue;
}
}
}
`````
This should be accepted by the compiler but it currently produces:
test.d(9): Error: case must be a string or an integral constant, not Foo
Tested with 2.066 and 2.069.
Comment #1 by github-bugzilla — 2015-12-03T06:17:52Z