Fix parameter-less out contracts of virtual methods with auto return type

These out contracts can still access the return value via __result.

LDC always passes the return value by reference to the out contract -
as long as there is a result (non-void). As the return type may still
need to be inferred in the first semantic pass, reserve a parameter
there and remove it later in semantic3() in case it is void (or finalize
its type).

Fixes compilable/test17502.
This commit is contained in:
Martin 2017-09-22 23:31:43 +02:00
parent 41aae46b91
commit 1fa90a0381
2 changed files with 36 additions and 9 deletions

View file

@ -1060,8 +1060,9 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
DtoCreateNestedContext(funcGen);
if (fd->vresult && !fd->vresult->nestedrefs.dim) // FIXME: not sure here :/
{
// Declare the special __result variable. If it's captured, it has already
// been allocated by DtoCreateNestedContext().
if (fd->vresult) {
DtoVarDeclaration(fd->vresult);
}