Comment #0 by bearophile_hugs — 2011-12-08T04:50:23Z
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[]
Comment #1 by clugdbug — 2012-06-13T05:03:17Z
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.
Comment #2 by robert.schadek — 2024-12-13T17:57:12Z