Bug 23985 – [dip1000] return scope fails to infer after assignment

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-06-10T17:11:22Z
Last change time
2024-12-13T19:29:39Z
Assigned to
No Owner
Creator
Dennis
Moved to GitHub: dmd#20298 →

Comments

Comment #0 by dkorpel — 2023-06-10T17:11:22Z
From the newsgroup: https://forum.dlang.org/post/[email protected] ```D // REQUIRED_ARGS: -preview=dip1000 @safe: struct B() { int* a; C!() c; } class C() { C!() foo(int* a) { return foo2(a); } C!() foo2(int* a) { auto b = B!()(a); return b.c; } } void main() { scope int* a; C!() c; // Error: scope variable `a` assigned to non-scope parameter `a` calling `foo` c.foo(a); } a); } ```
Comment #1 by timon.gehr — 2023-06-11T18:28:35Z
Do we really want `scope` inference on virtual methods? The code type checks without deprecation if you mark both methods as `final`.
Comment #2 by timon.gehr — 2023-06-11T18:45:41Z
If inferring `return scope` on `a` was not the intention, can you maybe clarify how a fix for this issue would work?
Comment #3 by dkorpel — 2023-06-11T20:28:14Z
(In reply to timon.gehr from comment #1) > Do we really want `scope` inference on virtual methods? Good point, I missed that the method is virtual. I think this would be invalid then. (Though of course the enhancement for separate lifetimes for separate aggregate fields still stands)
Comment #4 by robert.schadek — 2024-12-13T19:29:39Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20298 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB