www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2171] New: bizzare toCBuffer result when emit error message for bad source code

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

           Summary: bizzare toCBuffer result when emit error message for bad
                    source code
           Product: D
           Version: 1.030
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: davidl 126.com


// $HeadURL: svn://svn.berlios.de/dstress/trunk/run/t/this_13_C.d $
// $Date: 2007-01-01 03:59:08 +0800 (Mon, 01 Jan 2007) $
// $Author: thomask $

//  author      Frank Benoit <benoit tionex.de>
//  date        2006-10-09
//  uri         http://d.puremagic.com/issues/show_bug.cgi?id=419
//  desc        [Issue 419] New: Anonymous classes are not working.

module dstress.run.t.this_13_C;

interface I {
    void get( char[] s );
}

class C{
        void init(){
                I i = new class(){
                        void get( char[] s ){
                                func();
                        }
                };
        }
        void func( ){ }
}

int main(){
        C c = new C();
        c.init();

        return 0;
}

compile result with:
bug.d(18): Error: cannot implicitly convert expression ((class __anonclass1 :
Object
{
    void get(char[] s)
{
assert(this,"null this");  // this line is quite unreadable
this.this.func();          // also this.this.func is dummy
}
    C this;
}
) , new __anonclass1) of type dstress.run.t.this_13_C.C.init.__anonclass1 to
dstress.run.t.this_13_C.I


-- 
Jun 25 2008