digitalmars.D.bugs - [Issue 12265] New: Puritiy inference fails with passing template function as an alias?
- d-bugmail puremagic.com (42/42) Feb 26 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12265
- d-bugmail puremagic.com (10/10) Feb 26 2014 https://d.puremagic.com/issues/show_bug.cgi?id=12265
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 puremagic.com ReportedBy: dmitry.olsh gmail.com 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: -------
Feb 26 2014
https://d.puremagic.com/issues/show_bug.cgi?id=12265 Because of the issue 10134, current dmd does not infer attributes for the sortImpl!(cmp, T[]).sort. Related compiler code: https://github.com/D-Programming-Language/dmd/blob/master/src/func.c#L1122 https://github.com/D-Programming-Language/dmd/blob/master/src/func.c#L2108 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 26 2014