[Issue 24175] DIP1000 fails to determine proper lifetime for struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 6 21:11:36 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24175
apham <apz28 at hotmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |apz28 at hotmail.com
--- Comment #4 from apham <apz28 at hotmail.com> ---
SCOPE & dip1000 is not for prime-time yet. Still having bug & not easier to use
as below sample
@safe:
class C1
{
@safe:
int i;
}
struct A1
{
@safe:
this(C1 c1, return scope int[] a)
{
this.a = a;
this.c1 = c1;
this.c1s.reserve(10);
}
C1 compute()
{
return c1;
}
int[] a;
C1[] c1s;
C1 c1;
}
int main()
{
int n;
{ // Simulate a scope block
C1 c1 = new C1();
int[3] a = [1, 2, 3];
A1 a1 = A1(c1, a[]);
n = a1.compute().i;
}
return n;
}
onlineapp.d(18): Error: scope variable `this` assigned to non-scope parameter
`arr` calling `reserve`
/dlang/dmd/linux/bin64/../../src/druntime/import/object.d(3931): which
is not `scope` because of `cast(void[]*)&arr`
onlineapp.d(38): Error: scope variable `a1` calling non-scope member function
`A1.compute()`
--
More information about the Digitalmars-d-bugs
mailing list