Bug 23294 – [dip1000] parameter to parameter assignment leads to incorrect scope inference

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-08-15T12:51:41Z
Last change time
2024-07-19T12:47:06Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2022-08-15T12:51:41Z
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 lifetime But evidently, scope parameter inference does not care about relative lifetime of parameters, which is problematic when they have destructors.
Comment #1 by dlang-bot — 2023-01-27T15:15:48Z
@dkorpel updated dlang/dmd pull request #14492 "Fix 20674, 23208, 23300 - improve `scope` inference" fixing this issue: - Fix 20674, 23208, 23300, 23294 - improve `scope` inference https://github.com/dlang/dmd/pull/14492
Comment #2 by dlang-bot — 2024-07-19T11:16:33Z
@dkorpel created dlang/dmd pull request #16725 "Fix bugzilla 23294 - parameter to parameter assignment leads to incor…" fixing this issue: - Fix bugzilla 23294 - parameter to parameter assignment leads to incorrect scope inference https://github.com/dlang/dmd/pull/16725
Comment #3 by dlang-bot — 2024-07-19T12:47:06Z
dlang/dmd pull request #16725 "Fix bugzilla 23294 - parameter to parameter assignment leads to incor…" was merged into master: - 777d4f14877d74b27d02529ba5c255b6d7f40d52 by Dennis Korpel: Fix bugzilla 23294 - parameter to parameter assignment leads to incorrect scope inference https://github.com/dlang/dmd/pull/16725