infer returnScope when adding return and scope (#12938)

This commit is contained in:
Walter Bright 2021-08-01 03:44:47 -07:00 committed by GitHub
parent fa9a7961b8
commit cdd9063115
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -730,7 +730,7 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag)
{ /* v is scope, and va is not scope, so va needs to
* infer scope
*/
//printf("inferring scope for %s\n", va.toChars());
if (log) printf("inferring scope for %s\n", va.toChars());
va.storage_class |= STC.scope_ | STC.scopeinferred;
/* v returns, and va does not return, so va needs
* to infer return
@ -738,7 +738,12 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag)
if (v.storage_class & STC.return_ &&
!(va.storage_class & STC.return_))
{
if (log) printf("infer return for %s\n", va.toChars());
va.storage_class |= STC.return_ | STC.returninferred;
// Added "return scope" so don't confuse it with "return ref"
if (isRefReturnScope(va.storage_class))
va.storage_class |= STC.returnScope;
}
}
continue;