digitalmars.D.bugs - [Issue 23294] New: [dip1000] parameter to parameter assignment leads
- d-bugmail puremagic.com (33/34) Aug 15 2022 https://issues.dlang.org/show_bug.cgi?id=23294
https://issues.dlang.org/show_bug.cgi?id=23294 Issue ID: 23294 Summary: [dip1000] parameter to parameter assignment leads to incorrect scope inference Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: safe Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dkorpel live.nl x and y are inferred scope in the following example: ``` safe: int global; auto f(int* x, int* y) { x = y; global++; // make sure it's not inferring scope from pure } void g(scope int* z) { f(z, z); // passes } ``` When you mark `x` and `y` as `scope` explicitly, it errors:Error: scope variable `y` assigned to `x` with longer lifetimeBut evidently, scope parameter inference does not care about relative lifetime of parameters, which is problematic when they have destructors. --
Aug 15 2022