www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Bug 36] New: Odd enum forward-reference (?) alias bug

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=36

           Summary: Odd enum forward-reference (?) alias bug
           Product: D
           Version: 0.149
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: braddr puremagic.com
        ReportedBy: jarrett.billingsley gmail.com


This is an obscure one.

This code compiles, as expected:

enum E
{
        One,
        Two,
        Three
}

class A
{
        alias void delegate(E) EDG;

        static void fork(EDG dg)
        {
                dg(E.One);
        }
}

But move the alias declaration after the function:

class A
{
        static void fork(EDG dg)
        {
                dg(E.One);
        }

        alias void delegate(E) EDG;
}

And you get the cryptic error:

dtest.d(18): cannot implicitly convert expression (0) of type E to E

Maybe this has something to do with forward referencing?


-- 
Mar 11 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

d-bugmail puremagic.com schrieb am 2006-03-11:
 But move the alias declaration after the function:

 class A
 {
         static void fork(EDG dg)
         {
                 dg(E.One);
         }

         alias void delegate(E) EDG;
 }

 And you get the cryptic error:

 dtest.d(18): cannot implicitly convert expression (0) of type E to E

 Maybe this has something to do with forward referencing?

Added to DStress as http://dstress.kuehne.cn/run/a/alias_32_A.d http://dstress.kuehne.cn/run/a/alias_32_B.d http://dstress.kuehne.cn/run/a/alias_32_C.d http://dstress.kuehne.cn/run/a/alias_32_D.d http://dstress.kuehne.cn/run/a/alias_32_E.d http://dstress.kuehne.cn/run/a/alias_32_F.d http://dstress.kuehne.cn/run/a/alias_32_G.d http://dstress.kuehne.cn/run/a/alias_32_H.d http://dstress.kuehne.cn/run/a/alias_32_I.d http://dstress.kuehne.cn/run/t/typedef_13_A.d http://dstress.kuehne.cn/run/t/typedef_13_B.d http://dstress.kuehne.cn/run/t/typedef_13_C.d http://dstress.kuehne.cn/run/t/typedef_13_D.d http://dstress.kuehne.cn/run/t/typedef_13_E.d http://dstress.kuehne.cn/run/t/typedef_13_F.d http://dstress.kuehne.cn/run/t/typedef_13_G.d http://dstress.kuehne.cn/run/t/typedef_13_H.d http://dstress.kuehne.cn/run/t/typedef_13_I.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEFTQ23w+/yD4P9tIRAszaAJwPd3R3SEY9RtVofF4P684ATWJjCACguDWq o5vkdKEp7PeDQFxeWFtdjxs= =5y8X -----END PGP SIGNATURE-----
Mar 13 2006