digitalmars.D.bugs - [Issue 8638] New: built-in array opSliceAssign fails with user defined opAssign
- d-bugmail puremagic.com (36/36) Sep 10 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8638
- d-bugmail puremagic.com (27/27) Sep 12 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8638
- d-bugmail puremagic.com (23/23) Sep 16 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8638
http://d.puremagic.com/issues/show_bug.cgi?id=8638
Summary: built-in array opSliceAssign fails with user defined
opAssign
Product: D
Version: unspecified
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody puremagic.com
ReportedBy: monarchdodra gmail.com
In a word:
--------
struct S
{
void opAssign(int j);
}
void main()
{
int[] i;
i[] = 5; //Here1
S[] s;
s[] = 5; //Here2
}
--------
Actual behavior:
Here2: Error: cannot implicitly convert expression (5) of type int to S[]
Expected behavior:
Here2: opAssign(5) is called for each member of s, just like for Here1.
Ditto for all other flavors of opSliceSomething.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 10 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8638
The issue can be worked around as such:
--------
struct S
{
int i;
void opAssign(S);
void opAssign(int j);
}
void main()
{
ulong[] i;
i[] = cast(ushort)5; //Here1
S[] s;
s[] = S(5); //Here2
}
--------
However, this shifts the requirement:
*from isAssignable!(S,V)
*to isAssignable!(S,S) && "canBeConstructedFrom!(S, V)"
Where S is the user defined struct, and V is another type.
Note that the built-in opSliceAssign DOES support assignement of V to S
(HERE1), so there is indeed a limitation/bug/ER.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 12 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8638
monarchdodra gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |enhancement
Just wanted to document that the issue also exists for opOpAssign:
--------
struct S
{
void opOpAssign(int);
}
void main()
{
S[] ss;
ss[]+=1;
}
--------
Also, I'm not 100% sure if this is a bug or not, but I believe it *should*
work, so I'm re-labeling as ER
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 16 2012









d-bugmail puremagic.com 