Bug 22366 – [dip1000] scope variable can be assigned to associative array
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-10-08T14:44:57Z
Last change time
2021-10-11T22:13:39Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis
Comments
Comment #0 by dkorpel — 2021-10-08T14:44:57Z
Putting a scope variable in an associative array literal gives "scope variable `x` may not be copied into allocated memory". However, you can still assign it:
```
int* fun(scope int* x)
{
int*[int] aa;
aa[0] = x; // should give an error
return aa[0];
}
void main()
{
int x;
assert(fun(&x) != &x); // fails, demonstrating &x was escaped
}
```
Comment #1 by dlang-bot — 2021-10-11T11:16:56Z
@RazvanN7 created dlang/dmd pull request #13156 "Fix Issue 22366 - [dip1000] scope variable can be assigned to associative array" fixing this issue:
- Fix Issue 22366 - [dip1000] scope variable can be assigned to associative array
https://github.com/dlang/dmd/pull/13156
Comment #2 by dlang-bot — 2021-10-11T22:13:39Z
dlang/dmd pull request #13156 "Fix Issue 22366 - [dip1000] scope variable can be assigned to associative array" was merged into master:
- 69df082bd5425f9067001e23d0a806a7f7e0962d by RazvanN7:
Fix Issue 22366 - [dip1000] scope variable can be assigned to associative array
https://github.com/dlang/dmd/pull/13156