[Issue 11747] New: Better error message with @disabled toString

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 15 03:04:39 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11747

           Summary: Better error message with @disabled toString
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2013-12-15 03:04:33 PST ---
A low priority enhancement suggestion.

A way to disallow the printing of a struct is to use @disable on its toString:


struct Foo {
    @disable string toString();
}
void main() {
    import std.stdio;
    Foo f;
    writeln(f);
}



But the missing function is only detected at link time (dmd 2.065alpha):

test2.obj(test2) 
 Error 42: Symbol Undefined _D5test23Foo8toStringMFZAya


So perhaps it's better to add to write a template constraint that verifies
toString is not @disabled, to catch the problem at compile-time.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list