You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this program:
///// test.d ////
import std.conv;
void main()
{
to!int("\r");
}
/////////////////
will produce output which looks like this in a terminal:
' when converting from type string to type intbin/../phobos/std/conv.d(2168): Unexpected '
----------------
??:? pure @safe int std.conv.parse!(int, immutable(char)[]).parse(ref immutable(char)[]) [0x4331de]
??:? pure @safe int std.conv.toImpl!(int, immutable(char)[]).toImpl(immutable(char)[]) [0x436a70]
??:? pure @safe int std.conv.to!(int).to!(immutable(char)[]).to(immutable(char)[]) [0x432a83]
??:? _Dmain [0x432a5d]
The error message appears malformed.
std.conv.to should escape whitespace / control / non-printable characters in its error messages. Perhaps the existing functionality in std.conv / std.format can be reused: format!"%(%s%)"(c.only) will already correctly escape such characters.
See discussion in https://github.com/dlang/phobos/pull/5591 (which fixed this issue specifically for the newline character only) for more details.
The text was updated successfully, but these errors were encountered:
jrdemail2000-dlang commented on 2017-12-17T18:50:54Z
Encountered this case in my tools (https://github.com/eBay/tsv-utils-dlang/issues/96). A user was processing a DOS file (with `\r\n` line endings) on a Unix box, byLine left the extraneous `\r` at the end of the line. My tool tried to convert to double, and output the error text when this failed due to the `\r`. The formatting of the output is quite confusing, as `\r` actually repositions to the start of the line, effectively deleting the initial part of the output line. The result:
' when converting from type const(char)[] to type doubleUnexpected '
For my tools I'll add explicit detection of DOS line endings on Unix boxes, it's just too common when getting data files from a variety of sources. However, it'd be helpful to update error message generation to handle `\r` and other non-printing characters.
dlang-bugzilla (@CyberShadow) reported this on 2017-07-31T19:31:51Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=17708
CC List
Description
Currently this program: ///// test.d //// import std.conv; void main() { to!int("\r"); } ///////////////// will produce output which looks like this in a terminal: ' when converting from type string to type intbin/../phobos/std/conv.d(2168): Unexpected ' ---------------- ??:? pure @safe int std.conv.parse!(int, immutable(char)[]).parse(ref immutable(char)[]) [0x4331de] ??:? pure @safe int std.conv.toImpl!(int, immutable(char)[]).toImpl(immutable(char)[]) [0x436a70] ??:? pure @safe int std.conv.to!(int).to!(immutable(char)[]).to(immutable(char)[]) [0x432a83] ??:? _Dmain [0x432a5d] The error message appears malformed. std.conv.to should escape whitespace / control / non-printable characters in its error messages. Perhaps the existing functionality in std.conv / std.format can be reused: format!"%(%s%)"(c.only) will already correctly escape such characters. See discussion in https://github.com/dlang/phobos/pull/5591 (which fixed this issue specifically for the newline character only) for more details.The text was updated successfully, but these errors were encountered: