Bug 8176 – Error: cannot implicitly convert expression (record) of type CsvRecord!(string,cast(Malformed)0,string,dchar) to string
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-31T15:17:17Z
Last change time
2019-10-17T19:50:02Z
Assigned to
No Owner
Creator
Mariusz GliwiĆski
Comments
Comment #0 by alienballance — 2012-05-31T15:17:17Z
std.csv looks just great on the first glance, but it's a pain to use in reality.
One of the reasons is below:
private import
std.csv;
void process(string smth) {}
void main()
{
string str = "A \" is now part of the data";
auto records = csvReader!(string,Malformed.ignore)(str);
auto record = records.front;
assert(record.front == str);
process(record);
}
test.d(13): Error: function test.process (string smth) is not callable using argument types (CsvRecord!(string,cast(Malformed)0,string,dchar))
test.d(13): Error: cannot implicitly convert expression (record) of type CsvRecord!(string,cast(Malformed)0,string,dchar) to string
Comment #1 by bugzilla — 2019-10-17T19:50:02Z
The error is correct, because record is a range of strings, but process expects a string. Probably it was meant to use process(record.front). That compiles. So here is not really a bug.