mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Fix 23380 - class parameter should not be treated as ref qua lifetime (#14495)
This commit is contained in:
parent
0e3691c332
commit
375ab59ab1
2 changed files with 11 additions and 3 deletions
|
@ -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
|
||||
|
|
9
compiler/test/compilable/test23380.d
Normal file
9
compiler/test/compilable/test23380.d
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue