January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5290



--- Comment #10 from bearophile_hugs@eml.cc 2012-01-20 15:08:36 PST ---
(In reply to comment #9)
> (In reply to comment #0)
> > The following invalid code is accepted:
> > import std.stdio;
> > void main() {
> >     real[2] foo = [1.0L];
> >     writeln(foo);  // [1, 0]
> > }
> 
> Running it gives:
> 
> object.Exception@src\rt\arraycat.d(31): lengths don't match for array copy

D is statically typed, so it's better to refuse it at compile-time.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5290


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch


--- Comment #11 from timon.gehr@gmx.ch 2012-01-20 15:38:41 PST ---
Actually, it would be very cool if D would re-use the integer range trick here and catch all cases that can be proven not to work using it, such that the following code would error at compile time: ;)

int x;
readf("%d",&x);
real[2] foo =
    x%100>50 ?
    [1.0L, 2.0L, 3.0L][0..2|x&1] :
    ([1.0L, 2.0L] ~ [3.0L, 4.0L] ~ 5.0L)[x&1..$-!(x&1)];

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 24, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5290


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #12 from Don <clugdbug@yahoo.com.au> 2012-01-24 06:29:05 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #0)
> > > The following invalid code is accepted:
> > > import std.stdio;
> > > void main() {
> > >     real[2] foo = [1.0L];
> > >     writeln(foo);  // [1, 0]
> > > }
> > 
> > Running it gives:
> > 
> > object.Exception@src\rt\arraycat.d(31): lengths don't match for array copy
> 
> D is statically typed, so it's better to refuse it at compile-time.


Yes, but that's bug 2547.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
1 2
Next ›   Last »