diff --git a/compiler/src/dmd/hdrgen.d b/compiler/src/dmd/hdrgen.d index f3c6bbb56b6..013a0815345 100644 --- a/compiler/src/dmd/hdrgen.d +++ b/compiler/src/dmd/hdrgen.d @@ -1720,10 +1720,10 @@ void toCBuffer(Dsymbol s, ref OutBuffer buf, ref HdrGenState hgs) //printf("FuncDeclaration::toCBuffer() '%s'\n", f.toChars()); if (stcToBuffer(buf, f.storage_class)) buf.writeByte(' '); + typeToBuffer(f.type, f.ident, buf, hgs); auto tf = f.type.isTypeFunction(); - typeToBuffer(tf, f.ident, buf, hgs); - if (hgs.hdrgen) + if (hgs.hdrgen && tf) { // if the return type is missing (e.g. ref functions or auto) // https://issues.dlang.org/show_bug.cgi?id=20090 diff --git a/compiler/test/compilable/vcg_ast_compilable.d b/compiler/test/compilable/vcg_ast_compilable.d new file mode 100644 index 00000000000..e84846dfbe1 --- /dev/null +++ b/compiler/test/compilable/vcg_ast_compilable.d @@ -0,0 +1,69 @@ +/* +REQUIRED_ARGS: -vcg-ast -o- +OUTPUT_FILES: compilable/vcg_ast_compilable.d.cg +TEST_OUTPUT: +--- +=== compilable/vcg_ast_compilable.d.cg +import object; +auto binaryFun(E)(E b) +{ + return 'a' == b; +} +void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) +{ +} +void find()(string needle) +{ +} +void splitter() +{ + find(3); + find(""); +} +binaryFun!int +{ + auto pure nothrow @nogc @safe bool binaryFun(int b) + { + return 97 == b; + } + +} +find!int +{ + pure nothrow @nogc @safe void find(int needle) + { + } + +} +binaryFun!string +{ + auto _error_ binaryFun + { + __error__ + } + +} +find!() +{ + pure nothrow @nogc @safe void find(string needle) + { + } + +} +--- +*/ + +// https://issues.dlang.org/show_bug.cgi?id=24431 +auto binaryFun(E)(E b) +{ + return 'a' == b; +} + +void find(Element)(Element needle) if (is(typeof(binaryFun(needle)))) { } +void find()(string needle) { } + +void splitter() +{ + find!int(3); + find!()(""); +}