Bug 9615 – std.conv.parse!(T[]) fails on trailing comma
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-28T01:01:00Z
Last change time
2017-03-22T12:21:54Z
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2013-02-28T01:01:53Z
The D syntax (AFAIK) allows a trailing comma at the end of a list, for the sake of convenience, eg:
int a =
[
1,
2,
3,
];
(This *is* legal, right, it's not an accepts invalid?)
In any case, this code is currently legal, but std.conv.pase rejects it:
//----
int[] arr = [1, 2,]; //LEGAL
string s = "[1, 2,]"; //*SHOULD* work
parse!(int[])(s); //Unexpected ']' when converting from type string to type int
//----
Comment #1 by monarchdodra — 2013-02-28T01:12:58Z
(In reply to comment #0)
> parse!(int[])(s); //Unexpected ']' when converting from type string to type
> int
And if you are trying to parse a string[], you'll get a "Can't parse string: """ is missing"
Comment #2 by github-bugzilla — 2017-01-26T16:43:07Z