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
Comment #3 by github-bugzilla — 2012-05-07T20:39:52Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/07d34c1ae0b5283cf5bc22610d4401443549efaf Fix for BUG 4744, enum parsing will now test every member and select the one with the longest matching string https://github.com/D-Programming-Language/phobos/commit/36f5539e0a7315dee8e3613c540584857fc04008 Merge pull request #557 from Chabsf/master Issue 4744: std.conv: string->enum doesn't look for longer match