mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
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:
parent
41aae46b91
commit
1fa90a0381
2 changed files with 36 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue