[Issue 10960] New: Copying a const value type should yield unqual
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 3 16:09:27 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10960
Summary: Copying a const value type should yield unqual
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: hsteoh at quickfur.ath.cx
--- Comment #0 from hsteoh at quickfur.ath.cx 2013-09-03 16:09:25 PDT ---
This is from a forum post.
Code:
------
void main(){
auto A = [0, 1, 2];
const B = [10, -20, 30];
schwartzSort!(i => B[i])(A); // NG
}
------
This fails because the return type of the lambda is deduced as const(int). This
is silly since a copied const value type no longer needs to be const; it should
be unqual.
Explicitly naming the unqual type for the delegate fixes the problem:
schwartzSort!(delegate int (i) => B[i])(A); // OK
The user shouldn't be required to do this; returning a const value type by
value should be stripped of its constness, since it is not the original value
being returned, but a copy.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list