[Issue 12265] New: Puritiy inference fails with passing template function as an alias?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 26 01:08:13 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12265
Summary: Puritiy inference fails with passing template function
as an alias?
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: major
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: dmitry.olsh at gmail.com
--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2014-02-26 01:08:10 PST ---
Distilled from std.algorithm.sort and is a blocker for its purity inference.
Tested with DMD64 D Compiler v2.065-devel-671874e.
The test case:
// (things like this are introduced by binaryFun template)
bool cmp(T)(auto ref T a, auto ref T b) { return a < b; }
template sortImpl(alias pred, R)
{
void sort(R arr) //pure //fails to infer pure here
{
pred(arr[0], arr[1]);
}
}
T[] sorted(T)(T[] stuff)
{
//this works as pure
sortImpl!((a, b) => a < b, T[]).sort(stuff);
//this doesn't
sortImpl!(cmp, T[]).sort(stuff);
return stuff;
}
void main() pure
{
int[] a = [1, 8, 3, 16];
a = sorted(a);
}
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list