Bug 4744 – std.conv: string->enum doesn't look for longer match
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-27T23:04:00Z
Last change time
2012-05-12T08:43:22Z
Keywords
pull, rejects-valid
Assigned to
rsinfu
Creator
rsinfu
Comments
Comment #0 by rsinfu — 2010-08-27T23:04:37Z
parse!enum(string) must look for a longer match.
--------------------
import std.conv;
unittest
{
enum E { aa, aaZ, aaaZ }
assert(to!E("aaaZ") == E.aaaZ);
}
void main() {}
--------------------
% dmd -unittest -run test
std.conv.ConvError: std.conv(684): Can't convert value `Z' of type const(char)[] to type E
Comment #1 by yebblies — 2012-04-04T17:39:37Z
*** Issue 7821 has been marked as a duplicate of this issue. ***
Comment #2 by francois.chabot.dev — 2012-04-29T20:43:13Z