[Issue 8040] New: writeln(null) too

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 4 12:54:11 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8040

           Summary: writeln(null) too
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-05-04 12:55:24 PDT ---
Problem found by Ali Çehreli.

D2 code:


import std.stdio: writeln;
class Foo {}
struct Bar {}
void main() {
    Foo f = null;
    writeln(f);
    Bar* b = null;
    writeln(b);
    writeln(null);
}


Expected output similar to:

cast(Foo)null
cast(Bar*)null
null


DMD 2.056 prints "null" in the first two writeln, and gives errors for the
third one:

...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'length'
...\dmd2\src\phobos\std\stdio.d(1562): Error: undefined identifier 'ptr', did
you mean 'template tr(C1,C2,C3,C4 = immutable(char))'?
test.d(9): Error: template instance std.stdio.writeln!(typeof(null)) error
instantiating

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


More information about the Digitalmars-d-bugs mailing list