www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Wrong error message on forward reference bug

reply Lars Ivar Igesund <larsivar igesund.net> writes:
The code

void foo(dchar [] string = BAR) {}
const dchar [] BAR = "Bar";

won't compile with the message

constchar.d(1): cannot implicitly convert expression (BAR) of type 
dchar[] to dchar[]

Funny, heh?

Anyway, it compiles if you switch the lines, so I suppose it's a wrongly 
diagnosed forward reference problem. The same bug appears if foo and BAR 
are members of a class.

Lars Ivar Igesund
Apr 09 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lars Ivar Igesund schrieb am Sat, 09 Apr 2005 23:49:45 +0100:
 The code

 void foo(dchar [] string = BAR) {}
 const dchar [] BAR = "Bar";

 won't compile with the message

 constchar.d(1): cannot implicitly convert expression (BAR) of type 
 dchar[] to dchar[]

 Funny, heh?

 Anyway, it compiles if you switch the lines, so I suppose it's a wrongly 
 diagnosed forward reference problem. The same bug appears if foo and BAR 
 are members of a class.
Added to DStress as http://dstress.kuehne.cn/run/default_argument_08.d http://dstress.kuehne.cn/run/default_argument_09.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCWfdM3w+/yD4P9tIRAhB4AKCgPEvgdo7UwOlar3jlUQA0UPZjMwCdFZxl yHSduAOJ45hlYNZtyl1YPMc= =IZJx -----END PGP SIGNATURE-----
Apr 10 2005