Fix 23380 - class parameter should not be treated as ref qua lifetime (#14495)

This commit is contained in:
Dennis 2022-09-28 15:01:05 +02:00 committed by GitHub
parent 0e3691c332
commit 375ab59ab1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

@ -663,9 +663,8 @@ bool checkAssignEscape(Scope* sc, Expression e, bool gag, bool byRef)
FuncDeclaration fd = sc.func;
// Determine if va is a parameter that is an indirect reference
const bool vaIsRef = va && va.storage_class & STC.parameter &&
(va.isReference() || va.type.toBasetype().isTypeClass()); // ref, out, or class
// Determine if va is a `ref` parameter, so it has a lifetime exceding the function scope
const bool vaIsRef = va && va.isParameter() && va.isReference();
if (log && vaIsRef) printf("va is ref `%s`\n", va.toChars());
/* Determine if va is the first parameter, through which other 'return' parameters

View file

@ -0,0 +1,9 @@
// REQUIRED_ARGS: -preview=dip1000
// https://issues.dlang.org/show_bug.cgi?id=23380
// Issue 23380 - [dip1000] class parameter should not be treated as ref qua lifetime
@safe void test(scope Object o0, scope Object o1)
{
o1 = o0;
}