www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7081] New: BigInt array slice int assignment

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

           Summary: BigInt array slice int assignment
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



To manage BigInt arrays in a handy way (and in a way uniform with arrays of
integers), I'd like this code to work:


import std.bigint;
void main() {
    BigInt[5] arr;
    arr[] = 1;       // line 4
    arr[1 .. 3] = 2; // line 5
}


But with dmd 2.057beta it gives:

test.d(4): Error: cannot implicitly convert expression (1) of type int to
BigInt[]
test.d(5): Error: cannot implicitly convert expression (2) of type int to
BigInt[]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 08 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7081


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au
          Component|Phobos                      |DMD
            Summary|BigInt array slice int      |array slice assignment
                   |assignment                  |should check for opAssign



This doesn't have anything to do with BigInt. Rather, it's a request for
implicit conversion to apply to array block assignment.

Reduced example:

struct S
{
   void opAssign(int n) {}
}

void main()
{
   S[20] s;
   s[] = 6;
}

bug.d(9): Error: cannot implicitly convert expression (6) of type int to S[]

It seems reasonable enough. It could be problematic if the thing being assigned
is an array, eg

void opAssign(int[] n) {}

but we have that problem already with block assignment to arrays of dynamic
arrays.

AFAIK array block assignment isn't mentioned in the spec at all.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 13 2012