D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12260 - Improve error of std.stdio.readf when involving whitespace
Summary: Improve error of std.stdio.readf when involving whitespace
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
: 15297 (view as issue list)
Depends on:
Blocks:
 
Reported: 2014-02-25 19:56 UTC by Jesse Phillips
Modified: 2018-01-05 13:30 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jesse Phillips 2014-02-25 19:56:51 UTC
The following program will throw an exception on the second read.

------
void main()
{
    import std.stdio;
    int input;
    readf("%s", &input);
    readf("%s", &input);
}
------

The exceptions message points out the remaining newline from the first input:

--------
conv.d(1901): Unexpected '
' when converting from type LockingTextReader to type int
--------

It should probably convert whitespace into a more recognizable form:

-------
conv.d(1901): Unexpected '\n' when converting from type LockingTextReader to type int
-------
Comment 1 Dave Akers 2015-05-09 09:30:34 UTC
Current version of d 2.67.1 will skip the \n, for example the program...
------
void main()
{
    import std.stdio;
    int input;
    readf("%s", &input);
    readf("%s", &input);
}
------
Given the input...
------
1
2
------
Will emit the error...
------
std.conv.ConvException@/usr/include/dlang/dmd/std/conv.d(2013): Unexpected '2' when converting from type LockingTextReader to type int
------
Comment 2 Vladimir Panteleev 2017-07-18 13:04:00 UTC
*** Issue 15297 has been marked as a duplicate of this issue. ***
Comment 3 github-bugzilla 2017-07-31 15:37:18 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/afc732661a5cbdd69b22d5bffa57fddab76172ad
Fix Issue 12260 - Improve error of std.stdio.readf when involving whitespace

https://github.com/dlang/phobos/commit/63de27b5308b6bdb4e0489cc53e87e603f0c95cf
Merge pull request #5591 from RazvanN7/Issue_12260

Fix Issue 12260 - Improve error of std.stdio.readf when involving whitespace
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
Comment 4 github-bugzilla 2017-08-16 13:24:26 UTC
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/afc732661a5cbdd69b22d5bffa57fddab76172ad
Fix Issue 12260 - Improve error of std.stdio.readf when involving whitespace

https://github.com/dlang/phobos/commit/63de27b5308b6bdb4e0489cc53e87e603f0c95cf
Merge pull request #5591 from RazvanN7/Issue_12260
Comment 5 github-bugzilla 2018-01-05 13:30:49 UTC
Commits pushed to dmd-cxx at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/afc732661a5cbdd69b22d5bffa57fddab76172ad
Fix Issue 12260 - Improve error of std.stdio.readf when involving whitespace

https://github.com/dlang/phobos/commit/63de27b5308b6bdb4e0489cc53e87e603f0c95cf
Merge pull request #5591 from RazvanN7/Issue_12260