Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
March 10, 2007 [Issue 1048] New: the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
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]; -- |
March 10, 2007 [Issue 1048] the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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 --------------- -- |
March 10, 2007 [Issue 1048] the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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]; } -- |
March 10, 2007 Re: [Issue 1048] the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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]'.
|
March 10, 2007 Re: [Issue 1048] the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to torhu | "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 |
March 14, 2007 Re: [Issue 1048] the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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[]. :P
As 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.
|
September 04, 2009 [Issue 1048] the type matching of static initialization | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
Copyright © 1999-2021 by the D Language Foundation