Strange exception, with EXTREMELY SIMPLE toString() in a struct
rumbu via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 7 05:17:26 PST 2015
On Monday, 7 December 2015 at 08:17:27 UTC, Enjoys Math wrote:
> Exception Message:
> First-chance exception: std.format.FormatException Unterminated
> format specifier: "%" at
> C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(828)
>
> [CODE]
> module set;
> import std.conv;
>
> struct Set(T) {
> string toString() const {
> auto str = "{";
> return str;
> }
> }
>
> unittest {
> import std.stdio;
> auto A = Set!int();
> writeln(A);
> }
> [/CODE]
This is caused in fact by a correct unittest assertion in
format.d:
f = FormatSpec("a%%b%%c%");
w.clear();
assertThrown!FormatException(f.writeUpToNextSpec(w)); <-- here
assert(w.data == "a%b%c" && f.trailing == "%");
You can add std.Format.FormatException to the Exception Settings
(Debug -> Exceptions) and untick the Thrown checkbox.
More information about the Digitalmars-d-learn
mailing list