diff --git a/compiler/src/dmd/cppmangle.d b/compiler/src/dmd/cppmangle.d index b015a642b9..2cee596138 100644 --- a/compiler/src/dmd/cppmangle.d +++ b/compiler/src/dmd/cppmangle.d @@ -213,6 +213,11 @@ private final class CppMangleVisitor : Visitor { auto tf = cast(TypeFunction)this.context.res.asFuncDecl().type; Type rt = preSemantic.nextOf(); + // https://issues.dlang.org/show_bug.cgi?id=22739 + // auto return type means that rt is null. + // if so, just pick up the type from the instance + if (!rt) + rt = tf.nextOf(); if (tf.isref) rt = rt.referenceTo(); auto prev = this.context.push(tf.nextOf()); diff --git a/compiler/test/compilable/test22739.d b/compiler/test/compilable/test22739.d new file mode 100644 index 0000000000..6aeb5d60fd --- /dev/null +++ b/compiler/test/compilable/test22739.d @@ -0,0 +1,10 @@ +// https://issues.dlang.org/show_bug.cgi?id=22739 + +extern(C++) auto f(T)() +{ + return T.init; +} +void main() +{ + f!int; +}