1 // PERMUTE_ARGS: 2 // REQUIRED_ARGS: 3 4 /* 5 TEST_OUTPUT: 6 --- 7 output foo: 1e: pure nothrow @nogc @safe void(int x) 8 output foo: 3e: pure nothrow @nogc @safe void(int x) 9 --- 10 */ 11 12 alias void function(int) pure nothrow @safe @nogc FuncPtrType; 13 foo1a(X)14void foo1a(X)(X x) {} foo1b(X)15void foo1b(X)(X x) {} foo1c(X)16void foo1c(X)(X x) {} foo1d(X)17void foo1d(X)(X x) {} foo1e(X)18void foo1e(X)(X x) {} 19 20 // module level declaration with type inference 21 auto fptr1 = &foo1a!int; 22 static assert(is(typeof(fptr1) == FuncPtrType)); 23 24 // array initializer 25 auto fptrlist1 = [&foo1b!int]; 26 static assert(is(typeof(fptrlist1) == FuncPtrType[])); 27 28 // static assert 29 static assert(is(typeof(&foo1c!int) == FuncPtrType)); 30 31 // static if 32 static if(is(typeof(&foo1d!int) PF)) 33 static assert(is(PF == FuncPtrType)); 34 else 35 static assert(0); 36 37 // pragma test 38 pragma(msg, "output foo: 1e: ", typeof(foo1e!int).stringof); 39 foo2a(X)40void foo2a(X)(X x) {} foo2b(X)41void foo2b(X)(X x) {} foo2c(X)42void foo2c(X)(X x) {} 43 44 FuncPtrType fptr3 = &foo2a!int; // most similar to original issue 45 46 FuncPtrType[] fptrlist3 = [&foo2b!int]; 47 48 struct S{ FuncPtrType fp; } 49 S s = { &foo2c!int }; 50 foo3a(X)51void foo3a(X)(X x) {} foo3b(X)52void foo3b(X)(X x) {} foo3c(X)53void foo3c(X)(X x) {} foo3d(X)54void foo3d(X)(X x) {} foo3e(X)55void foo3e(X)(X x) {} 56 main()57void main() 58 { 59 auto fptr2 = &foo3a!int; 60 static assert(is(typeof(fptr2) == FuncPtrType)); 61 62 auto fptrlist2 = [&foo3b!int]; 63 static assert(is(typeof(fptrlist2) == FuncPtrType[])); 64 65 static assert(is(typeof(&foo1c!int) == FuncPtrType)); 66 67 static if(is(typeof(&foo1d!int) PF)) 68 static assert(is(PF == FuncPtrType)); 69 else 70 static assert(0); 71 72 pragma(msg, "output foo: 3e: ", typeof(foo3e!int)); 73 } 74