1 // https://bugzilla.gdcproject.org/show_bug.cgi?id=35 2 // { dg-do run } 3 // { dg-skip-if "needs gcc/config.d" { ! d_runtime } } 4 5 /** 6 * Here the BinaryHeap instance uses an alias parameter and therefore 7 * the instance's functions (percolateDown) need to be generated in 8 * topNIndex->BinaryHeap scope and not in the declaration scope 9 * (module->BinaryHeap). 10 */ topNIndex()11void topNIndex()() 12 { 13 bool indirectLess(int a, int b) 14 { 15 return a > b; 16 } 17 18 auto a = BinaryHeap!(indirectLess)(); 19 } 20 BinaryHeap(alias less)21struct BinaryHeap(alias less) 22 { 23 void percolateDown() 24 { 25 less(0, 1); 26 } 27 } 28 test35a()29void test35a() 30 { 31 topNIndex(); 32 } 33 34 /* 35 * Similar as test35a but with an additional indirection. 36 * The nested function chain for percolateDown should look like this: 37 * topNIndex2->BinaryHeap2->percolateDown. 38 */ topNIndex2()39void topNIndex2()() 40 { 41 bool indirectLess(int a, int b) 42 { 43 return a > b; 44 } 45 auto a = BinaryHeap2!(S35b!(indirectLess)())(); 46 } 47 S35b(alias a)48struct S35b(alias a) 49 { 50 void foo() 51 { 52 a(0, 0); 53 } 54 } 55 BinaryHeap2(alias less)56struct BinaryHeap2(alias less) 57 { 58 void percolateDown() 59 { 60 less.foo(); 61 } 62 } 63 test35b()64void test35b() 65 { 66 topNIndex2(); 67 } 68 main()69void main() 70 { 71 test35a(); 72 test35b(); 73 } 74