[Issue 24175] New: DIP1000 fails to determine proper lifetime for struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Oct 5 16:58:58 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24175
Issue ID: 24175
Summary: DIP1000 fails to determine proper lifetime for struct
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: grimmaple95 at gmail.com
Consider the code below:
```
struct A
{
this(int[] data) @safe { a = data; }
int[] a;
}
void main() @safe
{
int[3] test = [1, 2, 3];
A a = A(test);
}
```
It fails to compile with dip1000, saying:
Error: reference to local variable `test` assigned to non-scope parameter
`data` calling `this`
However, both `a` and `test` should have same lifetime and therefore this code
should be allowed
--
More information about the Digitalmars-d-bugs
mailing list