digitalmars.D.bugs - [Issue 1048] New: the type matching of static initialization
- d-bugmail puremagic.com (17/17) Mar 09 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1048
- d-bugmail puremagic.com (14/14) Mar 10 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1048
- d-bugmail puremagic.com (7/7) Mar 10 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1048
- torhu (3/15) Mar 10 2007 That's not static initialization. It needs to be at the module level
- Jarrett Billingsley (7/10) Mar 10 2007 I think maybe he's just getting terms mixed up.
- Stewart Gordon (5/10) Mar 14 2007 As I've begun to say before, array literals ought to be multi-typed in m...
- d-bugmail puremagic.com (12/12) Sep 04 2009 http://d.puremagic.com/issues/show_bug.cgi?id=1048
http://d.puremagic.com/issues/show_bug.cgi?id=1048 Summary: the type matching of static initialization Product: D Version: 1.007 Platform: PC OS/Version: Windows Status: NEW Keywords: rejects-valid Severity: major Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: wstring gmail.com The following code will cause a error: Error: cannot implicitly convert expression ([2,3,4]) of type int[3] to ubyte ubyte a[3] = [2, 3 ,4]; --
Mar 09 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1048 ------- Comment #1 from ddparnell bigpond.com 2007-03-10 03:41 ------- That worked for me. Windows XP SP2, DMD 1.007 ----------------- c:\temp>type test.d ubyte a[3] = [2, 3 ,4]; void main(){} c:\temp>dmd test.d c:\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi; c:\temp>dmd Digital Mars D Compiler v1.007 --------------- --
Mar 10 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1048 ------- Comment #2 from wstring gmail.com 2007-03-10 08:51 ------- It cannot works: void main(){ ubyte a[3] = [2, 3 ,4]; } --
Mar 10 2007
d-bugmail puremagic.com wrote:http://d.puremagic.com/issues/show_bug.cgi?id=1048 ------- Comment #2 from wstring gmail.com 2007-03-10 08:51 ------- It cannot works: void main(){ ubyte a[3] = [2, 3 ,4]; }That's not static initialization. It needs to be at the module level for that, or be declared as 'static ubyte a[3]'.
Mar 10 2007
"torhu" <fake address.dude> wrote in message news:esunvd$u81$1 digitalmars.com...d-bugmail puremagic.com wrote: That's not static initialization. It needs to be at the module level for that, or be declared as 'static ubyte a[3]'.I think maybe he's just getting terms mixed up. In any case, to be able to do this in a function, you have to write ubyte[3] a = [cast(ubyte)1, 2, 3]; The compiler isn't smart enough to figure out that maybe, just maybe, that array literal should be a ubyte[] instead of an int[]. :P
Mar 10 2007
Jarrett Billingsley Wrote: <snip>ubyte[3] a = [cast(ubyte)1, 2, 3]; The compiler isn't smart enough to figure out that maybe, just maybe, that array literal should be a ubyte[] instead of an int[]. :PAs I've begun to say before, array literals ought to be multi-typed in much the same way as string literals are. But even so, it should be possible to make the compiler treat it as an initializer rather than an array literal; then there would be no problem. Stewart.
Mar 14 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1048 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |clugdbug yahoo.com.au Resolution| |FIXED --- Comment #3 from Don <clugdbug yahoo.com.au> 2009-09-04 06:22:30 PDT --- This was still failing in DMD1.020, but was fixed by 1.041. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 04 2009