www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21916] New: Error message is obfuscated when using wrong

https://issues.dlang.org/show_bug.cgi?id=21916

          Issue ID: 21916
           Summary: Error message is obfuscated when using wrong format
                    specifier at compile-time
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P4
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: dlang-bugzilla thecybershadow.net

/////// test.d //////
import std.format;

void main()
{
    format!"%f"([1]);
}
/////////////////////

Currently produces:

.../std/format/package.d(748): Error: expression `FormatException(['I', 'n',
'c', 'o', 'r', 'r', 'e', 'c', 't', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', 's',
'p', 'e', 'c', 'i', 'f', 'i', 'e', 'r', ' ', 'f', 'o', 'r', ' ', 'r', 'a', 'n',
'g', 'e', ':', ' ', '%', 'f'], ".../std/format/internal/write.d", 1722LU, null,
null, 0u)` is not constant
.../std/format/package.d(1370):        while evaluating: `static assert(!e)`
test.d(5): Error: template instance `std.format.format!("%f", int[])` error
instantiating

--
May 12